TypeScript

TypeScript is an opensource programming language, which is a superset of Javascript. This language was originally developed at Microsoft and was later made opensource in Oct 2012.

TypeScript
TypeScript programmer

What is so special about TypeScript?

JavaScript was originally developed to handle simple applications. As applications started growing, the code became complex. Additionally, JavaScript wasn’t offering several concepts from standard object-oriented programming e.g. easy class definitions. It also didn’t offer type check and type of the variable was inferred at runtime.

TypeScript resolves problems like this. TypeScript scripts are compiled and converted into JS files. All the existing JS files are completely valid in TypeScript (in fact you can rename a JS file as TS file and can use it!!). However, the reverse is not true.

Key advantages of using TypeScript language:

  • Static Type (Optional): Developer can define a type of the variables and it will be checked during compile time. This helps in reducing the errors at runtime. Supported types are explained briefly in the section below.
  • OO support: Developer can define the classes and have OO implemented using TypeScript. They can use static functions, variable scopes, function overloading, interfaces and inheritance
  • JS compatibility: Existing Javascript files could be used as TypeScript files without any problem.
  • Modules: Allows to define your own modules as well as allows to combine external modules easily.

Supported variable types:

  • Any – default type – all JS variables get initially mapped to this type until their type could be inferred at runtime.
  • boolean
  • number (integer, long, short…)
  • string (string, char)
  • type[] (Arrays)

IDE support for TypeScript

  • MS Visual Studio
  • IntelliJ IDEA
  • Eclipse Plugin

TypeScript compiler compiles the “.ts” scripts to generate javascript code. During this compilation, the compiler checks for various errors, thereby reducing the problems getting detected at runtime.

Related Links

Related Keywords

AngularJS, Angular, Javascript, CoffeeScript, ECMAScript, Grunt, Node.js

3 Replies to “TypeScript”

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.