Why write
Angular apps in TypeScript?
You can write your applications in ES6 (and even in ES5), but we use TypeScript as a substantially more productive way for writing JavaScript, and here’s why:
* TypeScript supports types. This allows the TypeScript compiler to help developers by finding and fixing lots of errors during development before even running the app.
* Great IDE support is one of TypeScript’s main advantages. If you make a mistake in a function or a variable name, it’s displayed in red. If you pass the wrong number of parameters (or wrong types) to a function, the wrong ones show in red. IDEs also offer great context-sensitive help. TypeScript code can be refactored by IDEs, whereas JavaScript has to be refactored manually. If you need to explore a new library, just install its type definitions file, and the IDE will prompt you with available APIs, so you don’t need to read its documentation elsewhere.
* Angular is bundled with type definitions files, so IDEs perform type checking while using the Angular API and they offer context-sensitive help right out of the box.
* TypeScript follows the ECMAScript 6 standard and adds to it types, interfaces, decorators, class member variables (fields), generics, and the keywords `public` and `private`. Future releases of TypeScript will support the missing ES6 features and implement the features of ES7 (see the TypeScript “Roadmap” on GitHub at
http://mng.bz/Ri29).
* TypeScript interfaces allow you to declare custom types that will be used in your application. Interfaces help in preventing compile-time errors caused by using objects of the wrong types in your application.
* The generated JavaScript code is easy to read, and it looks like hand-written code.
* You can debug your TypeScript code in the browser (with the help of source maps)
* Angular Team recommends TypeScript and the framework itself (as well as RxJS 5) is written in TypeScript. Most of the code samples in the blogs, StackOverflow, and in the Angular documentation are given in TypeScript.
Regards
Yakov