TypeScript
Microsoft's typed superset of JavaScript, whose types are checked at build time and erased at runtime, and the deliberate trade-offs that made it the default for large web codebases.
TypeScript is JavaScript with static types. Microsoft released it in 2012, led by Anders Hejlsberg, the designer of C#. Any valid JavaScript is valid TypeScript, and a compiler checks the added type annotations, then strips them out to produce plain JavaScript. The types exist only at build time.
That design, type erasure, set TypeScript's character. It adds no runtime and can be adopted one file at a time. Existing libraries get types through declaration files, many of them written by the community in the DefinitelyTyped repository. Because types vanish at runtime, data arriving from outside, such as an API response or a form, isn't checked by them at all, which is why runtime Schema Validation libraries are common alongside it.
Its type system is shaped to fit how JavaScript is actually written:
- Structural typing. Two types are compatible if their shapes match, regardless of their names, the static counterpart of Duck Typing.
- Gradual typing. The
anytype turns checking off for a value, so a codebase can move from untyped to strict at its own pace. - Inference and narrowing. Most local types are inferred, as in Type Inference, and the checker follows control flow, so inside
if (typeof x === "string")it knowsxis a string. - Unions and literal types. Discriminated unions model the algebraic data type, letting the checker confirm every case is handled. Conditional and mapped types compute new types from old ones, a type language expressive enough to reach Turing Completeness.
TypeScript is deliberately unsound. Its designers listed soundness as an explicit non-goal, choosing convenience and compatibility over guarantees. In practice it catches a large class of everyday mistakes (typos, missing properties, wrong arguments) at the moment of typing, and makes Static Analysis such as rename-across-project reliable. Its real product is arguably the editor's language service, behind autocomplete and navigation even for plain JavaScript.
Flow, Facebook's competing checker, launched in 2014 and lost the ecosystem. By the 2020s most major frameworks and libraries were written in TypeScript, and it ranked among the most used languages on GitHub.
Two developments are changing how it runs. Node.js began stripping types natively in 2024 and 2025, running .ts files directly by erasing annotations without checking them. And in 2025 Microsoft announced a port of the compiler from TypeScript to Go, reporting about tenfold faster type checking for large projects. A TC39 proposal would let JavaScript engines ignore type syntax directly.
The build step usually belongs to the Bundler or a fast transpiler that strips types without checking them, while the full checker runs separately in the editor and in continuous integration. Source Maps connect the output back to the typed source.
See also2
JavaScript
The programming language of the web browser, written in ten days in 1995, standardized as ECMAScript, and now run everywhere from servers to build tools despite quirks it can never remove.
Web Platform10 connections
Generics
Writing code once over a type variable so it works for any type, how languages implement it by erasure or by copying, and what constraints on type parameters buy.
Computation & Algorithms7 connections
Linked from6
- BundlerWeb Platform
The tool that resolves an application's modules into the files a browser downloads.
- Duck TypingComputation & Algorithms
Treating an object as suitable for a role based on what it can do, not what type it's declared to be.
- GenericsComputation & Algorithms
Writing code once over a type variable so it works for any type, how languages implement it by erasure or by copying, and what constraints on type parameters buy.
- JavaScriptWeb Platform
The programming language of the web browser, written in ten days in 1995, standardized as ECMAScript, and now run everywhere from servers to build tools despite quirks it can never remove.
- Type InferenceComputation & Algorithms
A compiler deriving a value's type from how it's used, so a programmer doesn't have to write it down.
- Type SystemTesting & Verification
The rules a language uses to classify values and reject operations that don't fit, checked before the program runs or as it runs, and the cheapest form of verification most programmers use every day.