4 ms·
Oh yeah, I'll mention JSDoc @type tags - hard pass, if you can. Comments should have NO EFFECT AT ALL WHATSOEVER on code. They're comments. Everything should be
by metaloha 3y ago
Oh yeah, I'll mention JSDoc @type tags - hard pass, if you can. Comments should have NO EFFECT AT ALL WHATSOEVER on code. They're comments. Everything should be identical with and without them, they are 100% disposable. Moving any type of functionality into comments makes them brittle and now they can't be stripped out.
The suggestion to add a `.d.ts` file is good - it allows people who do use TS to be able to use strong/static typing while using your library, without you needing to add any kind of type support within your library. Just make sure it stays updated ;)
- eyelidlessness 3y agoJSDoc types don’t have any effect on how the code runs. They just document the types they’re commenting on. They’re conceptually exactly the same as a .d.ts companion file, and both are just different ways to achieve roughly the same thing as having TypeScript types directly in the source.