TypeScript Hello World

TypeScript Hello World Console

Now that we have installed TypeScript successfully, Let’s start with our first typescript program – TypeScript Hello World.

Open any editor of your choice and type the code given below:

File: helloworld.ts

function greeting(input){ 
	return "Hello, " + input;
}
 
let message = "World"; 
console.log(greeting(message));

The typescript code would be transpiled to the respective javascript code. Once, we compile the typescript file it will generate a javascript file.

TypeScript Hello World
Typescript is a superset of Javascript

Commands to compile and run this program:

>tsc helloworld.ts

>node helloworld.js

This will result in displaying “Hello World” in the browser’s console.

Hello World

In the next section, we will learn about declaring variables in typescript.