The beauty of TypeScript
TypeScript popularity has been increasing in the last few years, and it isn’t slowing down.
After a friend’s suggestion, I tried converting a few projects to TypeScript, and I fell in love.
What is TypeScript
Configuration and compilation speed where the blockers for many developers.
Now with @babel/typescript and the endless starters, these problems don’t exist anymore. For custom webpack & babel setup, adding TypeScript takes a couple of minutes.
Popular starters like create-react-app and gatsby already offer TypeScript as an opt-in feature.
Vuejs 3 will be written fully in TypeScript and already provides full TypeScript support.
Angular has been using TypeScript since the beginning.
Problems solved by TypeScript
The time I spend checking
localhost has decreased a lot. A typed system gives you more confidence in what your code is doing.
Another great time sink for me was the heavy
Lovecraftian data structures with 10 layers of nested objects are not an issue if their type is one click away.
Even writing tests using mock data takes less time.
Even onboarding becomes easier with TypeScript.
The typed system helps new developers understand the ropes of the code they have to work with.
If it doesn’t compile, it’s broken.
Code compilation catches issues that would otherwise need manual testing.
Some developers argue on the time sink that is having to deal with TypeScript. A tradeoff between time and safety.
It is like arguing you shouldn’t write tests because it takes time.
Airbnb calculated that adopting TypeScript could prevent 38% of their bugs. That’s more of a time sink than writing any type will ever be.