TypeScript has been increasing in its popularity for the last couple of years. Angular, one of the largest frontend frameworks, is using TypeScript. About 60% of JS programmers already use TypeScript, But why ?
Here are some reasons may change your mind:
- You can avoid masterfully-hidden-ninja errors: The freedom of dynamic typing often leads to bugs that not only decrease the efficiency of the programmer’s work, but can also grind development to halt due to increasing costs of adding new lines of code.
- It is easier to refactor code without breaking it significantly.
You should because:
- TypeScript is more explicit: Making types explicit focuses our attention on how exactly our system is built, and how different parts of it interact with each other. In large-scale systems, it is important to be able to abstract away the rest of the system while keeping the context in mind. Types enable us to do that.
You shouldn't because:
- You might not choose TypeScript for small projects and prototypes for your own use (totally not worth it).
My (recent) experience with TS in Vue.js, React.js & Backend generally (an unnecessary story you can skip)
My first experience with TS was actually with Angular (it was a university project and my first/last experience with that framework) and I really didn't know what is TS so I google it and knew that you can write JS in TS file without any problem so I did it.
My first real experience with TS was with Vue.js, I wanted to know what TS will benefit me in my code and it was actually good and weird at the same time (I got some horrible Java flashbacks while doing it) but I felt it wasn't necessary for my code at that time.
My second experience with TS was with a full-stack project (React.js as the frontend framework), that when I felt that TS is a significant solution for my barbarian JS code.
Overall, TypeScript is a great tool to have in your toolset even if you don’t use it to its full capacity. It’s easy to start small and grow slowly, learning and adding new features as you go.