Skip to content
AgileLogics
4 min read

Your First TypeScript Program

Prerequisites: Installing TypeScript

Create a file named hello.ts:

const message: string = "Hello, world!";
console.log(message);

Compile it to JavaScript, then run the result with Node:

npx tsc hello.ts
node hello.js

Expected output

Hello, world!

tsc (the TypeScript compiler) reads hello.ts and writes a plain hello.js file next to it — that generated file is ordinary JavaScript with the type annotations stripped out.