This is an article that wants to help when choosing between TypeScript and VanillaJs
First of all:
We need to define TypeScript
Type checking: This is one of the core functionality of TypeScript. It allows you to define types for every variable or returning function over VanillaJs.
Scalability: As you might know Javascrtipt itself is not a language specifically designed for larger projects. This means it laks of some important structural mechanisms like classes, modules or maybe interfaces. Here is where TypeScript with ES6 comes to help.
Compiling time type checking: This allows you to see a potential type bug that can cause an application to crash. It could mitigate the need of a unit testing.
Angular 2 is using it (not sure yet if it is an advantage): Angular team decided to use TypeScript for their new version.
A good initiative.
As you see in the title. This is a good initiative from Michrosoft’s team but type checking could be a con when we talk about litle applications. Implementing strict type checking could (in my very personal opinion) slow down development because we might need the flexibility that a non-typed language can offer, including TypeScript without the use of type checking is like doing nothing. If you are really likely to use full TypeScript features (even taking advantage of type checking) then it is a good idea to adopt it. Provided that you are just going to use structural mechanisms and love VanillaJs with its flexibility, I will higly encourage you to check ES6 with Babel (Kind of an interpreter for new unsuported features from ES6). ES6 Brings structural mechanisms to VanillaJs (yaaiii) and some other feature but with no type checking.
In my personal opinion
TypeScript adds some new optional “fancy” features that might or might not improve the quality of the code (depends on the context and the scalability of the app).
Just in the case it is extremely important types checking, we should use TypeScript, otherwise VanillaJs with ES6 implementations and BabelJs will be ok.
TypeScript will get you to use type strict validation, which is nice for early bug detection and helps to mitigate the need of unit testing. It brings structural mechanisms to the game (sounds good and allows you to scale larger applications) but ES6 also bring them as well with other features and can be used today with Babel. If we are going to use frameworks that require the strict use of TypeScript, we will need to use it.
- TypeScript official page: TypeScript
- Wikipedia ES6: Wikipedia ES6
Written by @vctr90