DEV Community

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

Collapse
 
joelbonetr profile image
JoelBonetR 🥇

So we understood that we need TS (I guess) the question you need to answer when starting a project is "How are we going to use TS on this project"?

Thoughts?

Collapse
 
brense profile image
Rense Bakker

ts-check + JSDoc !== Typescript

You lose all the power that Typescript offers like generics and type intersections and to do anything but the most basic stuff, you have to deep dive into JSDoc and learn a whole new language. Then when you have it all set up, some jackass comes in and forgets to update a JSDoc after changing a function and your code just falls apart like a house of cards.

Collapse
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

// @ts-check is from TypeScript pragma, it makes VSCode use TS to validate your code (to explain it on a simplified way).

Didn't read the post, did you? You can enforce it with the ESLint plugin JSDoc.

By the way:
type intersections JSDoc

On the other hand you're right with Generics, you cannot use them with this approach as far as I know.

Last but not least, it's somewhat worrying that you consider JSDoc (The standard way to document JS and TS code) a whole new language 😅

Thread Thread
 
brense profile image
Rense Bakker

Yes lets discuss what you consider a language. JSdoc has a learning curve. Its worrying that you would try to deny that or didnt get that point.