My view on TypeScript
TypeScript:name is:verb such:any a:article mistake:noun !:ponctuation
I've worked full time with TypeScript for 6 months and I never got really convinced. Stupid syntax, wrong philosophy, it makes you waste more time than you gain from using it.
Here are a few points if you consider switching to TS:
1. TypeScript will give you a false sense of security, because its whole assumption is that your code is safe once it's type safe. The truth is that around 20% of bugs come from mistyping, and that leave the majority of bugs there in your application.
2. Specifying types is boring. It could have been worth it at a time we had stupid editors, but now, editors like VS Code are really good at guessing variables types, so most of the time they get it right.
When they don't, or when you need to really type some specific object, JSdoc is just perfect for that. The advantage of JSdoc is that it's a comment around your code, it's not directives in your code.
3. TypeScript is time consuming. Yes, so you are all happy that your editor provides you with the nice suggestions with intellisense, and you believe that's thanks to TypeScript, but if you already write clean JS code and sometimes use JSdoc when needed, VScode will do it just as well without having to use TypeScript.
On the other hand, systematically having to specify types costs time and mental efforts. At the end of the day, this typing stuff bores developers out and that's why you end up with lots of :any here and there because at some point, your colleagues were just to tired or too much in a hurry to figure out which type they should have put.
All this type import plumbing eats your days.
I realised I had become a real TypeScript developer when I spent more time fixing stupid type errors and types warning messages to please the TypeScript compiler, than actually writing real code.
If you cannot fight them, join them.
Finally, if you want to make your code safer, invest your time in writing unit tests instead of spending hours fighting with types.
Some more readings on the topic:
- The TypeScript Tax - Eric Elliott: much more argumented than my small rant
- 7 really good reasons not to use TypeScript - Michael Krasnov
- Please put TypeScript down for a moment - Kris Guzman