Getting started with TypeScript(TS)

In this article we will gonna learn some basics of TypeScipt.

  1. Installation of TypeScipt
  2. Introduction of TypeScipt
  3. Getting started with TypeScipt
    • Basic data type

So let’s start…….

1.Installation of TypeScipt

Step 1: Install node.js . Node basically provides server side environment. By installing node we will get Node Package Manager(NPM).

Npm helps us to  install packages. Package is basically javascript file library which can be use in your project.

If you want to know node is installed or not then open your CMD and type following command

If you want to know version of node then
C:\Users\AM\Desktop\TypeScript>node -v

step 2: Now it’s time to install TypeScript
C:\Users\AM\Desktop\TypeScript>npm install -g typescript
Above command will install latest version of TS at global level. If you wants to install it locally(i.e for folder only) don’t use -g . To install older version use
C:\Users\AM\Desktop\TypeScript>npm install -g typescript@1.7.5

To know TS version use following command
C:\Users\AM\Desktop\TypeScript>tsc -version
Version 3.3.3333

step 3: We need some editor to write our code. Here i am using Visual Studio Code

2.Introduction of TypeScript

->TypeScript is a language.It’s a super set of JavaScript.
->Ts can be used where you want to write JavaScript.
->When compiled it generates JavaScript.
->TS provides compile time environment where JS lacks. Which means less exceptions or bugs.

->ECMAScript 6 is also called as  ES6 or ECMAScript 2015 or JavaScript 6. ->TypeScript is Extension of ES6
-> We can say JS(parent)->ES6(child of JS)->TS(child of ES6||JS6)

How Typescript make life easier???
function division(a, b) {
return a > b;

C:\Users\AM\Desktop\TypeScript>node practis.js

In the above example we have written simple javascript function which accepts two parameters compare it and returns the result. here we have pass two numbers.Let’s see what happens when we pass different type of parameter.

function division(a, b) {
return a > b;

C:\Users\AM\Desktop\TypeScript>node practis.js

When we pass one number and another string it also gets compared and result is true. This is wrong we can’t compare number with string. In the JavaScript we can’t specify data type of parameters. But in TypeScript you can specify type of arguments you want to accept. let’s see an example.

In the above example we have written function which will accept two parameter both of type number. If you try to pass string it will throw an error.

We are all set 😉 Let’s start with TypeScript Programming…..

let a="Welcome to JustCompile"

We have initialized one variable which stores string value. Next line print’s value of variable. Save file with .ts
Run that file with command
tsc practis.ts
after compilation we will get new Javascript file i.e practis.js.
here is the generated js file:
var a = "Welcome to JustCompile";

Now we have to execute this js file with
node practis.js

Welcome to JustCompile

To be continued……. 😉

Please follow and like us:
User Review
1 (1 vote)

Leave a Reply

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