I’m reviewing a JavaScript code base with JS Doc comments like this above...


I’m reviewing a JavaScript code base with JS Doc comments like this above every function and component:

I don't recommend this.

TypeScript provides actual type safety, with superior autocomplete, for about the same amount of work.

And yes, you can use TypeScript via JS Doc annotations like this if you prefer:

(note that the example above doesn't declare types)

But I generally recommend using real TypeScript since the JS Doc style has limitations.

More info: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html

To be clear, JSDoc comments are useful.

I’m just suggesting using TypeScript instead of putting type info in a comment.

View original on X