Easy learning with example program codes

Typescript hello world program

Let us start TypeScript programming with simple “Hello World!” example.

Create and save the file with .ts extension. In first line we declare a variable of string type. In second line we display the variable’s value at the terminal window.

TypeScript Hello World:

var message:string = "Hello World!" ;

As we discussed in earlier tutorials that TypeScript code will be converted into JavaScript Code. After the compilation of above TypeScript code following JavaScript code will be generated.

Translated code:

var message = "Hello World!";

Compile and Execute a TypeScript Program:

Comiple: Use below command on the terminal window for compilation.
tsc typeScriptFileName.ts
Note − Multiple files can be compiled at once.
tsc typeScriptFileName1.ts, typeScriptFileName2.ts, typeScriptFileName3.ts

Execute: Use below command on the terminal window for execution.
node typeScriptFileName.js

Try it:

JS Bin on

Please follow and like us:

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki