DEV Community

Discussion on: Toxic flexibility - a case for TypeScript

Collapse
 
latobibor profile image
András Tóth • Edited

I agree with you fully; lot of it is coming from JS itself and the fact TS is a superset. It's like the great sand worm in Dune: you have to know your way around and then you can ride it. It is by no means perfect.

You are not saved from learning some TS hacks like let timerId: ReturnType<typeof setTimeout> = ..., when you have to deal with a mixed environment (node and browser).

Typescript must be also be written a certain way to avoid conflicts - I am planning to write about that as well (mainly how (not) to use any and as using instead generics).

However when the puzzles are solved the working type system is super powerful and gives me a lot of confidence when I have to do renamings, usage checks and other every day things, not to mention how superful powerful is when you have just npm install-ed a library written in TypeScript and you get all the properties, parameters and return types immediately. Forces you to have a simpler API which I believe in the long run is a good thing.