DEV Community

Discussion on: To TS or not to TS, that is NOT the question. Is it?

 
jzombie profile image
jzombie

I have no disagreements with using JSDoc. I find it incredibly useful.

Manually managing a d.ts, however, I'm not sure about.

There's the potential of getting those types completely incorrect if manually managing that file separately.

I'd think that if the aim is to use d.ts without TypeScript, surely someone has written some sort of parser which could generate them from JSDoc itself.

At that point, I'd just recommend using TypeScript, however.

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

No no, that's nothing related with d.ts. It's just that writing JSDoc this way (check TS doc around JS Doc I linked before) and adding // @ts-check at the top of your JS files, VSCode will type check your variables, functions/methods and so on using TS behind the scenes.

Try it out quickly on a single JS file if you're curious so it will be more clear probably 😁