What is TypeScript?

By | May 6, 2018

What is TypeScript?

TypeScript is Get Converted into JavaScript at the End by TypeScript Compiler

Official WebSite for TypeScript is https://www.typescriptlang.org/

Try Using PlayGround of TypeScript WebSite

Setup Typescript

  • Must have Node JS in Your Machine
  • check Node js and npm in your machine
  • npm install typescript -g (Install TypeScript)

Using TypeScript

Running our first example of T.S Compile TS into JS tsc <Typescript File Name>

Or  Compile Multiple TS File one shot tsc <fileName>.ts <Folder/<Filename>.ts>

Example – Using DataTypes

Types Basics

e.g. let name = “Amit Srivastava”; name = 11; //  this is error in typescript

var name:string=“Amit”; var age:number = 21; var attend:boolean = true; var e:any=100; var arr:string[] = [“ram”,”shyam”];

Save in a X.ts compile it using tsc X.ts You will get generated JS.

Using Types in Function

function add(x:number, y:number):number{ return x + y; }

Using Types in Classes

Creating Class class Employee{

private static autoNumber:number=10;

private id:number;

public name:string; //default is public     salary:number;     protected designation:string;     constructor(name:string, public companyName:string){         this.name = name;         this.id = Employee.autoNumber++;


public print():void{

console.log(`Id is ${this.id} and Name is $

{this.name} and Company Name is $




var ram = new Employee(“Amit”,”Brain Mentors Pvt Ltd“); ram.print();

Leave a Reply

Your email address will not be published. Required fields are marked *