TypeScript

term

programmingweb dev

Kept in this browser · My desk

Microsoft's typed superset of JavaScript, announced on 1 October 2012, with version 1.0 on 2 April 2014; its lead architect is Anders Hejlsberg.

Announced as "a superset of JavaScript that combines type checking and static analysis, explicit interfaces, and best practices into a single language and compiler".

What it is. TypeScript is JavaScript with a static type system on top. Microsoft announced it on 1 October 2012 as a superset of JavaScript, so existing JavaScript is the starting point, and its compiler, tsc, checks the types and then emits plain JavaScript that any browser or runtime can execute. Version 1.0 followed on 2 April 2014, shipped with Visual Studio 2013, as an npm package and as source code.

How it works. The TypeScript Handbook spells out what happens to the types: annotations are not part of JavaScript, so no browser runs TypeScript unmodified; the compiler strips them out, and type annotations never change what the program does at run time. The same compiler can downlevel the code, rewriting newer ECMAScript constructs such as template strings into older ones for older engines. By default tsc still writes the JavaScript file even when it reports type errors, on the principle that a working JavaScript program being migrated should keep running; the noEmitOnError option stops that. TypeScript's types are structural: "type compatibility in TypeScript is based on structural subtyping", so two types with the same shape are interchangeable whatever they are called, in contrast with nominal typing. The handbook adds that the type system is deliberately not sound in places, allowing certain operations that cannot be known to be safe at compile time because they are useful and common.

Strictness. Checking is a dial, not a switch. The strict flag in the compiler configuration enables a family of checks for stronger guarantees of correctness, and the handbook singles out two: noImplicitAny, which reports variables whose type silently falls back to any, the type that turns checking off, and strictNullChecks, without which null and undefined are assignable to every other type, a habit the handbook calls the cause of countless bugs.

Origin and status. S. Somasegar's announcement described "a superset of JavaScript that combines type checking and static analysis, explicit interfaces, and best practices into a single language and compiler". Its lead architect is Anders Hejlsberg, also the designer of C#. The compiler is itself a program in a language: in March 2025 the team announced a native port written in Go to reduce most build times by 10x; on the Visual Studio Code codebase, about 1,505,000 lines, a check fell from 77.8 to 7.5 seconds, 10.4 times faster. Hejlsberg wrote that the JavaScript-based compiler would continue into the 6.x series and that the native codebase would be released as TypeScript 7.0 once it reached parity; on 23 November 2026 the npm registry listed 7.0.2 as the latest version of the typescript package, under the Apache-2.0 licence.

In practice. Microsoft presented TypeScript 1.0 as a language designed with large-scale JavaScript application development in mind, and it is now read directly by runtimes: Node.js added type stripping in v22.6.0, enabled it by default in v23.6.0 and v22.18.0 and declared it stable in v25.2.0 and v24.12.0; it replaces the TypeScript syntax with whitespace and performs no type checking, so tsc still has to run somewhere in the build.

What goes wrong. Because the types are erased, nothing checks data that arrives at run time: a JavaScript Object Notation (JSON) body from the network or a value from a user has whatever shape it has, whatever the annotation claims, and must be validated by code. Any annotation of type any, an unchecked cast, or the deliberately unsound corners of the type system let a wrong value through silently. TypeScript projects also install their dependencies from npm, the registry the Cybersecurity and Infrastructure Security Agency (CISA) warned about on 23 September 2025, when a self-replicating worm known as Shai-Hulud had compromised more than 500 packages and harvested GitHub personal access tokens and cloud keys for Amazon Web Services (AWS), Google Cloud Platform (GCP) and Microsoft Azure; CISA asked developers to rotate credentials, require phishing-resistant multi-factor authentication (MFA) and harden their GitHub settings.

Neighbours. JavaScript, which it compiles to and whose run-time behaviour it never changes; type-system, where its structural typing sits; C#, its designer's earlier language; Go, the language of its native compiler; and supply-chain-attack, the risk it shares with every npm project.

Also known as: ts language, typed javascript

Sources

← Back to T Back to the glossary