create file name: index.ts as below
1 2 3 |
var greeting:string = "Hello, I am Shrikant" ; //declare and initialize string variable var age:number =30 //declare and initialize number variable console.log(greeting + ' and my age is: ' + age ) |
save the file and run the below command:
1 |
tsc index.ts |
it will compile the typescript file to JavaScript and generate below file as index.js
1 2 3 |
var greeting = "Hello, I am Shrikant"; //declare and initialize string variable var age = 30; //declare and initialize number variable console.log(greeting + ' and my age is: ' + age); |
to see output run JavaScript file with below command :
1 |
node index.js |
Output:
Hello, I am Shrikant and my age is: 30