Typescript Introduction

TypeScript is an open-source object-oriented programming language and it’s a typed superset of JavaScript that compiles to plain JavaScript that means the code whatever we wrote in typescript will be compiled into plain JavaScript code by Typescript compiler.


The Typescript was implemented by Microsoft and the first version (0.8) of TypeScript was released in October 2012. Same as other object-oriented languages such as c#, java, etc. the typescript also offers classes, interfaces, access modifiers, etc. to build robust components.


The browsers won’t understand the code whatever we wrote in Typescript due to that you need to install the TypeScript compiler either globally or in your workspace to compile and convert TypeScript source code to JavaScript.


Generally, we will write the TypeScript code in a file with .ts extension and the typescript compiler (TSC) will compile and convert .ts extension file to plain JavaScript file with tsc filename.ts command like as shown below.


Typescript compilation process diagram


The generated JavaScript file (tutlane.js) can be included in HTML code and that will be executed by any browser.

Why TypeScript?

Basically, JavaScript is not a strict type checking language which means we can assign any value to the defined variables like as shown below.


var test = "Hello world";

test = true;

test = 1001;

test = undefinded

test = ['A','B', 'C']

If you observe the above code, we defined test variable and we are able to assign the values of different data types such as string, number, Boolean, etc. due to this, it’s difficult to maintain the large scale applications when other team members also working on the same code.


TypeScript is a strict type checking language so the compiler will associate the type to the variable at the time of variable initialization based on the value or defined type.


For example, in TypeScript the compiler will assign the string type to the following variable based on the assigned value.


let test = 'Welcome to Tutlane';

 The strict type system will help us to improve the code readability and find the errors at the compile time itself.


The TypeScript includes all the features of ES6 and ES7 versions of JavaScript and the additional features like object-oriented programming, cross-platform, etc. to build the large-scale JavaScript applications.

TypeScript Advantages

The following are the advantages of using TypeScript in our applications.


  • TypeScript is an open-source object-oriented programming language and it is supported & maintained by Microsoft.
  • TypeScript will support all the latest features of JavaScript and it is having additional features like type checking, object-oriented concepts, etc.
  • As discussed, after the TypeScript code compilation the generated JavaScript code will run on any browser or JavaScript engine.
  • The TypeScript will highlight the errors in code during the compilation time itself.
  • Code reusability will improve with TypeScript due to the object-oriented programming support.
  • TypeScript will provide great tooling support like autocompletion, type checking and source documentation in your code editor to build the applications faster.
  • TypeScript is easy to learn due to the coding syntax is similar to other object-oriented programming languages such as C# and Java.
  • The TypeScript has a definition file with .d.ts extension to provide support for external JavaScript libraries such as jQuery, AngularJS, etc. to avail the benefits of type checking, autocompletion, and member documentation.

TypeScript Features

The following are the important features of TypeScript.


  1. Type Inference: When we assign the value to our variable in TypeScript that will assign the type automatically, there is no need to explicitly define the type for that variable.
  2. Object-Oriented Language: TypeScript will support Object-Oriented Language features such as classes, interfaces, generics, modules, etc. By using this developer can write the code for both client-side and server-side application development. 
  3. Static Typing: The TypeScript will use static typing to detect errors while writing the code. So, there is no need to run your code every time, if there is any error it will show at compile time so the developer can write scripts easily.
  4. Cross-Platform: The TypeScript will execute on any platform where JavaScript runs on.
  5. Intellisense: The TypeScript will provide great tooling support with IntelliSense in the code editor to provide active hints while writing the code.

History of TypeScript

The TypeScript was developed and maintained by Microsoft under the Apache 2 license. The first version (0.8) of TypeScript was launched in October 2012 under the lead of Anders Hejlsberg who is the creator of c#. Now, the latest version of TypeScript is 3.7 which was released in November 2019.