It's incredibly validating to me to hear everyone questioning .

I've been hating it's guts for like 4 years now, saying that people should just use

Glad y'all are finally getting off the hype-train!

#webdev #js #javascript #jsdoc #typescript

Last updated 1 year ago

Ricard Torres · @ricard
420 followers · 2177 posts · Server ricard.social

๐Ÿ’œ Loved this new video about

I have been advocating for instead of going full TS for years.

โžก๏ธ youtube.com/watch?v=5ChkQKUzDC

#fireship #typescript #jsdoc #Frontend #JavaScript #webdevelopment

Last updated 1 year ago

Aral Balkan · @aral
39280 followers · 27653 posts · Server mastodon.ar.al

This took me way too long to figure outโ€ฆ

If your function takes a parameter object and uses spread syntax to collect arbitrary additional properties (rest) and you want to document it using , the syntax is:

[p:string]:any

e.g.,

```js
/**
@param {{
state: import('./SetupState.script.js').default,
[p:string]:any
}} parameterObject
@returns {string|string[]} html
*/
export default ({state, ...props}) => html`โ€ฆ`
```

Solution by Alexander Lonberg stackoverflow.com/a/68567492

#jsdoc #js

Last updated 1 year ago

Aral Balkan · @aral
39079 followers · 27270 posts · Server mastodon.ar.al

A little tip:

If you need to use a type definition in an external file multiple times, you donโ€™t have to keep writing `import(โ€ฆ).type` over and over. Just create a new type definition in your local file and use that.

e.g.,

```js
/** @typedef {import('./SetupState.js').SetupStateType} SetupStateType */

const state = {
domain: /** @type SetupStateType */ (new SetupState('Domain')),
server: /** @type SetupStateType */ (new SetupState('Server')),
โ€ฆ
}
```

#jsdoc #js #web #dev

Last updated 1 year ago

Rodion Borisov · @vintprox
103 followers · 1449 posts · Server techhub.social

@grooovinger @castastrophe @kizu @rach

Since generics were not working very well in 6 months ago, I still have this lingering feeling that tossing right away in favor of JSDoc is going to hurt some projects. If the situation with "templates"/generics has been resolved since then, then I would be able to seriously suggest moving to such opt-in commenting.

#jsdoc #typescript

Last updated 1 year ago

I love it when a library lets you choose between and in the code examples, but I wish that they would include the types in the version since they don't hurt anything and they are still helpful when you're using

#webdev #vscode #js #jsdoc #typescript #javascript

Last updated 1 year ago

Aral Balkan · @aral
35594 followers · 25694 posts · Server mastodon.ar.al

- is a wonderfully dynamic language and its dynamic features afford you a great deal of expressiveness.

- Strong typing is useful for catching errors before runtime.

These two statements donโ€™t have to be mutually exclusive.

Instead of shackling yourself to โ„ข 2023โ„ข Enterprise Editionโ„ข, you can use to get the best of both worlds.

Here, for example, Iโ€™m mixing in a property into Polka request handlers and documenting it. Intent is clear and type checker is happy.

#javascript #typescript #jsdoc

Last updated 1 year ago

T6961676F · @T6961676F
3 followers · 11 posts · Server fosstodon.org

Interesting things about what you can do with that alone doesn't let you do. syntax.fm/show/624/is-jsdoc-be

#jsdoc #typescript

Last updated 1 year ago

Aral Balkan · @aral
34528 followers · 24799 posts · Server mastodon.ar.al

PS. Some :

You can refer to types in other modules.

```
async createOrUpdate (/** @type import('stripe').Stripe */ stripe) {
// โ€ฆ
}
```

You can cast (note the parenthesis surrounding the cast):

```
state = /** @type RegistrationFormStateType */ (new RegistrationFormState())
```

You can annotate parameters inline:

```
function formattedMinimumPriceForCurrency (/** @type string */ currency) {
// โ€ฆ
}
```

For more advanced uses, see Closure Type System: github.com/google/closure-comp

#jsdoc #tips

Last updated 1 year ago

Aral Balkan · @aral
34529 followers · 24798 posts · Server mastodon.ar.al

Want strong typing without a build process?

(Hint: you donโ€™t need to use TypeScript.)

1. Use a modern editor like Helix Editor or VSCodium that supports the TypeScript Language Server (LSP).

2. Add this to the top of your JavaScript file (without the backticks):

```
// @ts-check
```

3. Go read up on JSDoc ;)

ยน helix-editor.com
ยฒ jsdoc.app/about-getting-starte

#javascript #typesafety #jsdoc #lsp #HelixEditor #typescript #web #dev

Last updated 1 year ago

Thilo Maier · @thilo
182 followers · 155 posts · Server maier.social

The discussion vs. with , triggered by a sound byte of @rich_harris, always derails into a type safety or not train wreck.

Everyone wants type safety for anything deployed in prod (hopefully). But there are different ways to get there.

JSDoc is just an alternative way of using TypeScript. But itโ€™s still TypeScript.

reddit.com/r/sveltejs/comments

#typescript #jsdoc #sveltekit

Last updated 1 year ago

Aral Balkan · @aral
33959 followers · 24534 posts · Server mastodon.ar.al

SystemError typedef for Node.js (gist)

codeberg.org/aral/gists/src/br

Node.js doesnโ€™t expose the SystemError class in any way. This JSDoc type definition works around this limitation.

#nodejs #codeberg #gist #jsdoc

Last updated 1 year ago

Thilo Maier · @thilo
173 followers · 119 posts · Server maier.social

@schizanon @thudfactor Last Friday's This week in looked at vs. :

youtu.be/sRhZQ-2VxVU?t=2420

Starts at 40:20.

#svelte #jsdoc #typescript

Last updated 1 year ago

Daniel ๐Ÿ™ Deboer · @dandb
120 followers · 1855 posts · Server mas.to

's module support is not to my liking.

And by not to my liking I mean hot garbage.

#jsdoc

Last updated 1 year ago

@thilo I've not used external definitions much personally, except when I need to import a type from a library. @enhance_dev does a great job of using for types in their docs. @see: enhance.dev/docs/learn/practic

#typescript #jsdocs #jsdoc

Last updated 1 year ago

Thilo Maier · @thilo
163 followers · 59 posts · Server maier.social

@schizanon @thudfactor I am in the process of converting my site from to TS.

Do you have any recommendations on how to complement JSDoc comments with .d.ts files?

I found that type definitions in .d.ts files and then importing them into JSDoc comments makes things easier.

But Iโ€™m having a hard time finding code bases that use JSDoc to learn from.

#sveltekit #typescript #jsdoc

Last updated 1 year ago

so I built a plugin for that contains some functionality like โ€œautomatic @inheritDocโ€, where if you neglect to document T, and T overrides/implements U, the result will copy the documentation from U into T when rendered. would anyone find this useful? if so I may release it standalone.

#typedoc #typescript #jsdoc

Last updated 1 year ago

Can't believe I'm about to share content, but version 5.0 adds support for @satisfies and @overload to and that's p cool ๐Ÿ‘

let's you type functions that can take different arguments which seems bad but w/e devblogs.microsoft.com/typescr

is some TS bs bullshit I haven't figured out yet but which is probably useful sometimes devblogs.microsoft.com/typescr

I just like to see parity with JSDocs and TS Syntax!

#satisfies #overload #jsdoc #typescript

Last updated 2 years ago

is there some way to use @typedef to import a type but not create a new one and/or not export it?

I think this is my main pain-point with for . if the thing youโ€™re importing has type args, you seem to have to duplicate them or have โ€œimport(..).Fooโ€ everywhere. am I missing something? can I use triple-slash directives somehow?

#jsdoc #typescript

Last updated 2 years ago

"I am using the fetch API to fetch some , how can add to the response using to check types in using annotations?"

#programming #ai #chatgpt #jsdoc #javascript #typescript #types #json

Last updated 2 years ago