Skip to content

Helloworld with Typescript

Install Typescript

Install tsc compiler
$ npm install -g typescript
  changed 1 package, and audited 2 packages in 3s
  found 0 vulnerabilities

Validate typescript version
$ tsc -v
  Version 4.6.2

Compile and run a typescript file

Create helloworld.ts file
$ cat   helloworld.ts
let message: string = 'Hello World';
console.log(message);

Compile it 
$ tsc  helloworld.ts

Valide js File creation
$ ls   helloworld.js
  helloworld.js

Finally run it
$ node   helloworld.js
  Hello World

Optional: Use Typscript Playground

Published inTypescript

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *