Table of Contents Preface typescript angular

Introduction

Type­Script was de­signed by An­ders Hejls­berg at Mi­crosoft to help write en­ter­sprise scale JavaScript.[1] It is a su­per­set of JavaScript with op­tional sta­tic typ­ing and has sup­port for ES­2015 fea­tures like classes, arrow functions and template literals.

Many teams from large com­pa­nies have con­tin­u­ally ar­rived at the con­clu­sion that adding types en­hances qual­ity and un­der­stand­abil­ity of code.[2] How­ever sta­tic typ­ing does add com­plex­ity and vi­sual clut­ter. Es­pe­cially if you need to man­u­ally spec­ify a type (like in Java). For­tu­nately Type­Script does not force you to use types and will try to in­fer as much type in­for­ma­tion as it can in or­der to give you type safety. As a re­sult Type­Script can pro­vide com­pile time type safety for your JavaScript code.

Be­sides bee­ing a stronlgy-typed lan­guage, one of the biggest sell­ing points of Type­Script is the tool­ing it pro­vides. IDEs can take ada­van­tage of fea­ture like ad­vanced au­to­com­ple­tion and code nav­i­ga­tion to im­prove the de­vel­op­ment ex­pe­ri­ence. Es­pe­cially dis­play­ing er­rors that oth­er­whise would only show up once the code is de­ployed to the browser saves a lot of time and frus­ta­tion. Also, the fact that in­tel­lisense and ba­sic refac­tor­ing (e.g. re­nam­ing a sym­bol) are re­li­able makes a huge im­pact on the process of writ­ing and refac­tor­ing code.

While Type­Script greatly im­proves the cod­ing ex­pe­ri­ence, it adds an ad­di­tional step to the build process. Since browsers can not in­tepret Type­Script your code has to be tran­spilled to JavaScript. But since you usu­ally have a com­plex build process that is han­dled by a task run­ner any­way the added com­plex­ity can eas­ily be solved by us­ing an ex­ist­ing plu­gin, like gulp-type­script[3].


  1. Anders Hejlsberg - Introducing TypeScript

  2. Statically typed JavaScript via Microsoft TypeScript, Facebook Flow and Google AtScript

  3. TypeScript plugin for Gulp