I work with Angular 1 for years now, and I'm starting to learn how to use Angular 2 instead.
But before writing any line of code, I struggle to whether I have to use TypeScript or JavaScript.
- What are the pros and cons using TypeScript ?
- What are those for using plain old JavaScript ?
Bonus question :
- Is there a best practice for choosing between JavaScript and TypeScript in an Angular 2 context ?
I don't know TypeScript but from the few pieces of code I have seen, it seems the major features are :
Type hinting
Prototype mechanisms hidden under a most common used Class syntax.
My first impressions after browsing the web :
Type Hinting :
I love type hinting, but I think it's a little overkill to use a new language just to add this feature and will produce more work for the devs to use libraries with loose type (from the docs, there is some ways to do this).
Class-based styntax :
What about the new class syntax (which is close to the ES6) ? The Prototypes are the most misunderstood feature of JavaScript but I think it's more important to understand how it works (to know what you really do) than simply put it aside.
ES5 is a Prototype-based programming language so why do you want to use a pseudo Class-based programming language, which will eventually produce prototypes ? It seems weird to me.
Code generation :
The last point is about code generator. I've already used code generator in other context, and I don't really like it : in most case, a human will produce a better written code (I have taken a look to the generated js : anonymous functions, anonymous function everywhere !) and more concise (when it comes to load the generated js files in the browser the size is important to reduce loading)
To conclude :
For instance I'm not really convinced of the interest to learn TypeScript instead of sticking to ES5 JavaScript. So I would like to have feedbacks from the community to know the advantages of using TypeScript.