What is TypeScript?
TypeScript is a typed superset of Javascript that compiles to plain JavaScript. It adds static typing, using type Annotation, which enables type checking at the compile-time and also adds class-based OOPS concepts to JavaScript. As we know, TypeScript is a superset of JavaScript, which makes any JavaScript program a valid TypeScript program. It is a free, open-source and cross-platform programming language developed and maintained by Microsoft. Even AngularJS 2.0 is written in TypeScript.
In this article, we will use the Visual Studio code editor to create a Hello World Application in TypeScript.
Let’s begin
Go to https://nodejs.org/en/ and Download Node.js (which is a JavaScript runtime built on Chrome’s V8 runtime engine).
Once the download is complete, install Node.js.

Now, open CMD prompt in order to install TypeScript. We will use NPM (Node Package Manager) to install TypeScript. (In image 1 given below, the command is used to install the latest stable TypeScript version and 2 is editors used for TypeScript).
Type NPM install -g TypeScript command.
Type tsc -version in order to check the installed version of TypeScript.
There are several code editors available like Visual Studio Code, Sublime, WebStorm, Eclipse, Vim, etc. In this series, we will use the Visual Studio Code as a code editor. Visit https://code.visualstudio.com/ and click Download.
Install Visual Studio code editor.
After installing, click Explorer icon and then click Open Folder. I have created a folder named HelloWorldinTS. Click Select Folder.
Click Add New File and name it as app.ts (You can name it, as you want).
Add the code given below in app.ts.
- class MyFirstApp {
- _Name: string;
- constructor(public Name: string) {
- this._Name = Name;
- }
- ShowHelloMessage() {
- console.log("Hello " + this._Name)
- }
- }
- let objMyFirstApp = new MyFirstApp("Anoop");
- objMyFirstApp.ShowHelloMessage();
Here, I have created a class with a constructor that takes name parameter of type string and a method, which prints Hello [Name] as an output on the console. Subsequently, I created objMyFirstApp object of that class and invoked ShowHelloMessage (We will learn in-depth about each thing in my upcoming article on TypeScript).
Now, press Crtl+Shift+P to open the command palette, type Tasks and select Run Build Task (We can compile it, using tsc in the command prompt but, in this article, I will show you how to compile or build it using Visual Studio code). Select Run Build Task (or Press Crtl+Shift+B).
After clicking, you will see an alert, i.e. no task runner is configured. Click Configure Task Runner.

Amit KumarPosted Feb 28, 2017, 12:12 PM
Nice explanation Anoop, Go forword.....
Pankaj Kumar ChoudharyPosted Feb 28, 2017, 12:12 AM
Nice Efforts Anoop, Explain all thing in very easy way....
Vishal PrajapatiPosted Feb 27, 2017, 11:23 PM
Nice explanation...