Polyglot
Languages TypeScript
Volume TypeScript

TypeScript

A statically typed superset of JavaScript developed by Microsoft. Adds compile-time type checking to a JavaScript program and emits plain JavaScript suitable for any conforming runtime.

Paradigms
imperative · OOP · functional
Typing
static
Memory
gc
Version
5.7
First released
2012

TypeScript is a statically typed programming language developed by Microsoft. It is a strict syntactic superset of JavaScript: every valid JavaScript program is a valid TypeScript program. The TypeScript compiler performs type checking against an explicit or inferred type system and emits equivalent plain JavaScript suitable for execution by any conforming ECMAScript runtime — the browser, Node.js, Deno, or Bun. The type system is structural rather than nominal: two types are compatible when their members are compatible, regardless of the names under which they were declared. The compiler enforces type discipline at translation time only; the runtime executes untyped JavaScript and the type information is erased during emission.

History

TypeScript was designed by Anders Hejlsberg and a team at Microsoft and was first released publicly as version 0.8 in October 2012. TypeScript 1.0 shipped in April 2014. The language gained substantial adoption following the 2016 release of Angular 2, which adopted TypeScript as its principal authoring language. TypeScript 2 (2016) introduced control-flow-based type analysis, non-nullable types under strictNullChecks, and discriminated unions. TypeScript 3 added tuples in rest parameters and improved generic inference. TypeScript 4 introduced variadic tuple types and template literal types. TypeScript 5 (2023) reduced the size of generated declaration files and introduced support for ECMAScript decorators. The current revision is TypeScript 5.7, with releases following an approximately quarterly cadence.

Hello world

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

Compilation and execution with the standard toolchain:

tsc hello.ts          # produces hello.js
node hello.js

Direct execution of TypeScript source — without an explicit emit step — is supported by ts-node, tsx, the Bun runtime, and Deno’s native TypeScript loader. A typical project provides a tsconfig.json that configures the compiler:

{
    "compilerOptions": {
        "target": "ES2022",
        "module": "ESNext",
        "strict": true,
        "moduleResolution": "Bundler",
        "skipLibCheck": true
    }
}

The strict family of options — strictNullChecks, noImplicitAny, strictFunctionTypes, and others — enables the additional checks that distinguish TypeScript from a permissive JavaScript-with-annotations dialect. New projects conventionally enable strict: true.