Hello, World in TypeScript
Print a line of text with a typed variable. Press Run to try it, then change the code and run it again.
const message: string = 'Hello, World!';
console.log(message);
Output
Press Run to see the output.
More TypeScript examples
- Interfaces and objects · Describe the shape of an object and use it in a function.
- Generics · Write one function that works with any type, safely.
- Union types and narrowing · Handle values that can be one of several types.
- Catch a type error · See how TypeScript stops a bug before the code runs.
- Async and await · Wait for promises with typed results.