Hello World
Write a .ts file
Save this as hello.ts. Types are optional at first; TypeScript still helps as you grow.
const message: string = "Hello, TypeScript!";
console.log(message);
Compile to JavaScript
From the same folder, run the compiler. It creates hello.js.
tsc hello.ts
Run the output
Use Node to execute the emitted JavaScript.
node hello.js
Fix a type mistake early
If you assign the wrong kind of value, tsc reports it before you run the program.
let count: number = 3;
// count = "three"; // Error: Type 'string' is not assignable to type 'number'
Comments
One comment per signed-in account. Comments are saved with this page’s URL.