TypeScript

6.0.3 · active · verified Sat Apr 18

TypeScript is a superset of JavaScript that adds optional static typing, enabling robust tools for large-scale application development across any browser, host, or OS. The current stable version is 6.0.3. New stable versions are typically released every few months, preceded by beta and release candidate versions, ensuring a predictable upgrade path.

Common errors

Warnings

Install

Imports

Quickstart

Installs the TypeScript compiler, creates a sample TypeScript file, compiles it to JavaScript using the `tsc` command, and then executes the resulting JavaScript file.

npm install -D typescript

// Create a file named 'hello.ts'
// console.log(`
// function greet(name: string) {
//   console.log(`Hello, ${name}!`);
// }
// 
// greet("World");
// greet(123); // This will cause a TypeScript error
// `);

// Compile the TypeScript file
npx tsc hello.ts

// Run the compiled JavaScript file
node hello.js

view raw JSON →