Since it’s creation back in 2012, the Typescript use has been growing mainly because Google decided to use it as the default language for his Angular framework. If we take a look to the stateofjs.com website, we can see that the insteret for using Typescript is growing each year but: what is Typescript and why should I use it?.
What exactly is Typescript?
What makes Typescript “superior”?
|Type checking||Dynamically-typed: The type of a variable is checked during run-time, variables are bound to objects at run-time, and it is possible to bind the same variables to objects of different types during execution.||Statically-typed: The type of a variable is known at compile-time, once a variable has been declared with a type, it cannot ever be assigned to some other variable of different type and doing so will raise a type error at compile-time.|
|Generics||N/A||Enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods.|
|Structural typing||N/A||Allows to relate types based solely on their members.|
|Object Oriented Programming||Prototype based, syntax sugar for classes. Interfaces are not supported.||Enables abstract classes, interfaces, visibility modificators and much more.|
Use the right tool for the job
So, it seems that there all just advantages but since Typescript needs to be transpiled we require time to setup everything, VanillaJS is “universal” to put it in some way, so I would say that for small projects it doesn’t worth the effort.
Now, is we are talking about medium or large projects, with a team (several people), Typescript can avoid us errors before deploying and we can take advantage of the characteristics we saw earlier.
So, in conclusion my advice is: use it for medium/large projects, you will see the benefits in short and medium term.