Why TypeScript was created
In general, it doesn’t matter that much which one you choose. The most important question is if it fulfills your needs. Anyway, there are some reasons why TypeScript is worth paying attention to. Let’s take a look at some numbers about JS and TS.
Chart from State of JS with opinions about TypeScript over time
On the screenshot above we’ve got opinions about TypeScript in recent years. In 2016, the sum of “would use again” and “interested” was 59.4%, in 2020 it increased to 87.7%!
Benefits of using TypeScript
The most important thing about TypeScript is that it provides types. It means that instead of remembering the type of each structure in the codebase, we can just write it. It’s essential when a project is getting large and will be maintained in the future.
Big projects have a tendency to change developers working on it over time. TypeScript takes responsibility for doing part of their work.
Apart from that, it’s easier to refactor the code, provide big changes and estimate the time they may take. Last but not least, it’s also easier to debug the parts of the code that are not working.
How much it costs
“With great power there must also come great responsibility”
Its downside is quite logical: it needs to be learned. Learning of course takes time and we should be aware of that. Luckily, as it was shown before, TypeScript gets more and more popular and it slowly begins to be a standard in bigger projects.
Another thing is, it takes a bit more time to develop things – we need to think about types, model structures and write additional code.
Is TypeScript mature enough to use it?
Initial version of TypeScript appeared in late 2012. Some time from that moment has passed. Awareness of this technology has increased which was shown on screenshots from State of JS above. Also the number of features, support for libraries and IDEs is way better than before.
Interesting thing about the team behind the TypeScript project is that its core developer is Anders Hejlsberg. He is a lead architect of C# and a creator of Delphi and Turbo Pascal. All of these technologies were quite important in the history of software development.
What projects is TypeScript suitable for?
Actually, the title of this article suggests an answer. And here are some details about that thesis. Basically, it’s definitely worth considering in each project that is going to be maintained in the future. In the beginning the profit might be hard to notice, but after some time it definitely pays off.
On the other hand, plain JS may still be a good option for doing proof of concept or writing small pieces of code.