All you need to know about Typescript!

Continuing with the series “All you need to know about” today with Typescript
First of all, a brief list of pro/cons in my opinion:

Advantages:

  • Use Types allows autocomplete and better tooling.
  • Type checking allows you to make the code more solid.
  • Warn you of common problems in js(types mixes, wrong returns types)
  • Easy adaptation of the actual code(you can work with js code or integrate them as is).
  • Full integration in Visual Studio Code(if you use it) and great tooling on major editors.
  • Create your own Types and apply them to refactoring
  • You can start it simple and when the code becomes more complex, you can add more control with Types and interfaces.
  • Appropriate errors if you are using es5, es6, etc.
  • Minimal changes to adapt your code to es6, es5, etc(and if you use an unsupported feature the compiler warns you).

Disadvantages:

  • If you don't have types for some external library you have to mark everything with Any Type(most features get lost in that mode).
  • Sometimes, valid code (but not quite correct solutions) will mark your error and you need to figure out how to solve it.
  • Another language to learn.
  • Another tool to build your code.

How to install it, and first steps:

Install Node Package Manager (npm)

$ curl http://npmjs.org/install.sh | sh
$ npm --version 1.1.70

Install the TypeScript npm package globally in the command line:

$ npm install -g typescript
$ npm view typescript version
npm http GET https://registry.npmjs.org/typescript  
npm http 304 https://registry.npmjs.org/typescript  
0.8.1-1  

Any modern browser: Chrome is used for this tutorial Any text editor: Sublime Text is used for this tutorial
Syntax highlighting plugin for text editors

Fundamental book:

https://www.gitbook.com/book/basarat/typescript/details

Official documentation:

https://www.typescriptlang.org/docs/tutorial.html

Courses:

https://egghead.io/technologies/typescript

Playground to modify code:

https://www.typescriptlang.org/play/index.html

Visual Studio Code support:

https://code.visualstudio.com/docs/languages/typescript

Another good guide:

https://www.sitepen.com/blog/2013/12/31/definitive-guide-to-typescript/

Opinion articles:

https://www.triplet.fi/blog/i-was-wrong-about-typescript-here-is-why/
http://walkercoderanger.com/blog/2014/02/typescript-isnt-the-answer/

Please, feel free to comment or contact us. You can take a look our Brochure too or visit our Works.

Source: https://code.tutsplus.com/tutorials/getting-started-with-typescript--net-28890