Getting Started With TypeScript Using Visual Studio Code

This is a fresh series of articles to learn Typescript from scratch, using Visual Studio code. Visual Studio Code is the new editor given by Microsoft, as it’s a very rich tool in comparison to sublime text, although this is my personal observation.

There are certain prerequisites before you jump into Typescript. Kindly follow the given steps in order to start with TypeScript.

  1. TypeScript is a very rich language, which is written in JavaScript, which follows an object oriented concept also.You can download TypeScript latest version here. Currently, TypeScript 2.1 is now available.

  2. Kindly download Visual Studio Code here. The latest version 1.8 is now available.

  3. VS Code has support for JavaScript and TypeScript languages out-of-the-box, as well as Node.js debugging. However, to run a Node.js application, you will need to install Node.js runtime on your machine. Node Package Manager alias npm is required for TypeScript through VS Code. Kindly refer to this link to install NPM. 

After following all of the above steps it’s time to verify the NPM, using command prompt.

Open the command prompt, and type the following statement - npm -v.


Here is a glimpse of Visual Studio Code



Install Typescript compiler using npm command

npm install -g typescript

It shows the screen given below after installing TypeScript compiler.


Once you are done with all the steps shown above, it's time to execute you first sample .ts file. I’ve created a file with the name test1.ts and it has content, as shown below in the image.


Open your command prompt and reach to the desired destination, wherever you have placed this file and execute the below command: tsc test.ts.

After running the statement shown above, it should create a test1.js file, which should also have the same contact as test1.ts file.


Now, you can also verify it, using node with the command: node test1.js is also depicted below in the image.


I hope you will have inferred the basics of TypeScript with Node and Visual Studio Code.

There is a lot more  in the upcoming articles.