TypeScript:JavaScript
A layer of static types over JavaScript that catches errors at compile time. Once dismissed as engineering ceremony — fourteen years later it is GitHub's #1 language by contributors and the native tongue of the Claude Code / Cursor / VS Code generation of AI tools.
past JS / Python · Octoverse
State of JS 2024
2025 Go-native rewrite
2025 academic study
What is TypeScript
TypeScript is a superset of JavaScript. Any valid JS is valid TS; TS layers on optional, erasable type syntax. It moves type errors from "found in production at 3am" to "underlined the moment you save the file."
All JS is valid TS, unchanged. Adoption is gradual — file by file, repo by repo.
Types only exist at compile time. tsc emits plain JS — browsers and Node never see them. Zero runtime overhead.
Duck typing made formal. Two types are compatible if their shapes match — no inheritance required. Far more flexible than Java's nominal model.
You rarely write types yourself. The compiler infers from assignments, return values, call context. JS-shaped code, TS-grade safety.
const user = { name: "Anders", age: 64 };
// One typo
console.log(user.naem.toUpperCase());
// → undefined
// → TypeError: Cannot read properties
// of undefined (reading 'toUpperCase')
// Discovered 3 hours into prodconst user = { name: "Anders", age: 64 };
// One typo
console.log(user.naem.toUpperCase());
~~~~
// ✘ Property 'naem' does not exist
// on type '{ name: string; age: number; }'.
// Did you mean 'name'?
// IDE stops you the moment you saveHistory : Timeline
From an internal Microsoft project pitched to Java / C# engineers, to swallowing half of the JavaScript ecosystem, to a 2025 Go rewrite of its own compiler.
- 2010
Internal kick-off
Anders Hejlsberg — father of Turbo Pascal, Delphi and C# — started a quiet project at Microsoft: give JavaScript a type system strong enough to carry large applications. The codename stayed secret for years; the original team was a handful of people.
- 2012·10
0.8 goes public
October 1st: TypeScript ships on GitHub. The first release pitched optional static types, classes, and modules. Most of the JS community shrugged at "JS with types"; only the Java/C# crowd was thrilled.
- 2013·06
0.9 — generics arrive
June 18th.
<T>lands in TS. Once generics existed, TS could finally describe container types (Array<T>,Map<K, V>) and the rich signatures of real libraries. - 2014·04
1.0 stable + Angular bet
April 12th, at Microsoft Build, TS 1.0 ships. The same year Google decided to rewrite Angular 2 in TypeScript — TS's first major framework endorsement. After this it stopped being "a Microsoft thing."
- 2016·09
2.0 — strict null checks
September 22nd.
--strictNullChecksremovednullandundefinedfrom all types — the team's pitch was killing Tony Hoare's "billion-dollar mistake." This is when TS started being type-serious. - 2018
Vue 3 rewritten in TS + tuples
September: Evan You announces Vue 3 will be rewritten in TypeScript. That July, TS 3.0 shipped variadic tuples — a leap in expressive power for libraries. The React crowd was migrating en masse around the same time.
- 2020·05
Deno 1.0 — TS as a first-class citizen
Node's creator Ryan Dahl ships Deno, with TypeScript baked into the runtime — no separate
tscstep. TS 4.0 followed in August. - 2022·11
4.9 — the
satisfiesoperatorSolves an old wart: how to constrain an object literal by a type without losing its precise literal inference.
satisfiesbecame the community's new favorite keyword almost overnight. - 2023·03
5.0 — modern decorators
March 16th. Stage-3 ECMAScript decorators land, retiring 7 years of
--experimentalDecorators. By this point, TS is already one of the highest-downloaded dev dependencies on npm. - 2024
State of JS: 78% of devs adopted
State of JS 2024: ~78% of respondents use TypeScript; over half write mostly TS, almost no plain JS. Five years of straight growth. The same year, Node.js 22+ shipped experimental type-stripping.
- 2025·03
Project Corsa — compiler rewrite in Go
Anders himself announces a Go port of
tsc. The 1.5M-line VS Code codebase type-checks in 7.5s instead of 78s — a 10.4× win. The native build will ship as TypeScript 7.0. - 2025
GitHub's #1 language
GitHub Octoverse 2025: TypeScript becomes GitHub's #1 language by contributors for the first time, past JavaScript and Python. Over a million new TS contributors that year, +66% YoY. Code-gen tools of the AI era almost unanimously emit TS.
Type System Essentials : TypeAlphabet
The type system is Turing-complete — you can solve SQL queries or compute Fibonacci at compile time, if you must. But 90% of day-to-day work uses the seven primitives below.
Type inference
Assignment shape dictates type. For most variables you simply don't write types.
const name = "Anders";
// hover ▸ const name: string
const user = { name: "A", age: 64 };
// { name: string; age: number; }
const tags = ["ts", "js"] as const;
// readonly ["ts", "js"]Unions + type guards
| joins alternatives; typeof / in / discriminant fields narrow each branch.
type Shape =
| { kind: "circle"; r: number }
| { kind: "square"; side: number };
function area(s: Shape) {
if (s.kind === "circle")
return Math.PI * s.r ** 2;
return s.side ** 2;
}Generics
Functions, classes and types parameterized over type variables. One implementation, all types.
function last<T>(arr: T[]): T | undefined {
return arr[arr.length - 1];
}
last([1, 2, 3]); // T = number
last(["a", "b"]); // T = stringUtility types
A toolbox of built-in type transforms. Change one source type and a slew of derived types track it.
type User = { name: string; age: number };
Partial<User> // all optional
Required<User> // all required
Pick<User, "name"> // just name
Omit<User, "age"> // without age
Readonly<User> // all readonly
Record<string, User> // dictionaryConditional types + infer
If-else at the type level. infer extracts a piece of type from a pattern match.
type IsArray<T> =
T extends any[] ? true : false;
IsArray<number[]> // true
IsArray<string> // false
type ReturnType<F> =
F extends (...a: any) => infer R ? R : never;Template literal types
String interpolation, but at the type level. Powers IDE features like full-string-path autocomplete.
type Greet<N extends string> =
`Hello, ${N}!`;
type X = Greet<"World">;
// "Hello, World!"
type Path = `/api/${"users" | "posts"}/:id`;Mapped types
Walk every property of a type and transform it. Utility types themselves are built this way.
type Stringify<T> = {
[K in keyof T]: string
};
type S = Stringify<User>;
// { name: string; age: string; }Types as a DSL
Composed together, these seven give you full-arg autocomplete, exhaustive union checking, and one-shot field rename — right in the editor.
"Maintainable at scale" isn't a slogan — it's a contract laid down one type signature at a time."
Why TS : WhyTS
Types aren't a cage — they're a tool. You sign a contract with your future self the moment you write the code.
Inference, not ceremony
Most variables don't need annotations; the compiler infers from context. You write code that looks like JS and get the protection of TS — small cost, big payoff.
const name = "Anders";
// hover: const name: stringEditor superpowers
Go-to-definition, find-references, rename refactors, method autocompletes — the things that are semi-magic in JS work concretely in TS, driven by types. VS Code itself is written in TS.
user.|
┌─ name : string
├─ age : number
└─ email?: stringSane at scale
Airbnb's 2019 retrospective: 38% of production bugs would have been caught by types. VS Code (1.5M lines of TS), Slack and Asana all walk this road.
// Change one prop, IDE
// flags all 47 call sitesGradual migration
From a // @ts-check comment to a .ts file to strict mode — adopt file by file, no big-bang rewrite. Airbnb and Slack went exactly this way.
// @ts-check
// One line, JSDoc starts workingNo ecosystem holes
The DefinitelyTyped repo carries 9,000+ @types/* packages — coverage for nearly every popular JS library. 85% of the npm top-1000 ship or have community types.
npm i -D @types/node
// Most libs need just one lineTypes as docs
A signature tells callers exactly what to pass and what they get back. Comments can never beat a line like (input: User) => Promise<Order[]>.
function fetchOrders(
user: User
): Promise<Order[]>LLM-friendly
A 2025 study: 94% of LLM compilation failures are type-check errors — TS catches AI mistakes before they ship. Anders himself: "Static typing is the AI era's guardrail."
// LLM emitted: User.naem
// tsc errors instantly
// agent self-corrects on feedbackClean output
Types disappear after tsc. Zero runtime cost — no VM, no runtime reflection. Production still runs plain JavaScript.
// input user.ts
const x: number = 42;
// output user.js
const x = 42;One contract, every layer
Shared schemas across backend / frontend / mobile. tRPC's end-to-end inference, Next.js / Nuxt server functions returning typed responses — no more drifting interface docs.
// shared/types.ts
export type Order = { ... };
// frontend / backend / mobile
// import the same typeWho's Using : ProductionUsers
IDEs, frameworks, enterprise codebases, and the hottest AI tools — TS is the de-facto JS-world standard. The 12 below carry roughly half the apps a developer opens on a given day.
TypeScript in the : AI Era
In the 2010s, writing TS was often mocked as trading JavaScript's nimbleness for type noise. The AI era flipped the wind — code-generating LLMs need a type system as a guardrail. This chapter is why TypeScript became the AI tool chain's native tongue.
"An AI model is fundamentally a regurgitator at scale, with a bit of extrapolation. The more public code in a language, the better AI writes it. Strong type systems, reliable refactoring, accurate semantic models — these are the guardrails that let AI output be reviewed, verified and corrected, instead of trusted blindly. Static typing catches AI mistakes before they become production problems.
GitHub Octoverse 2025: TS becomes GitHub's #1 language by contributors for the first time, past JavaScript and Python. Over a million new TS contributors that year, +66% YoY.
A 2025 academic study: when LLM-generated code fails to compile, the overwhelming majority of failures are type-check errors. Translation — TS is the last guardrail on LLM output.
Provider-agnostic TS toolkit unifying OpenAI / Anthropic / Google / xAI behind one API. Over 20M monthly downloads — the de-facto standard at the AI application layer on npm.
Claude Code
An agentic coding assistant that lives in your terminal, taking natural-language commands across git / editing / debug. Its source was reconstructed in March 2026 from a leaked source map — ~512,000 lines of TypeScript. Stack:
- React + Ink — React's declarative syntax, but for terminal UI
- Bun — Runtime — faster cold start than Node, eats TS natively
- main.tsx / commands.ts / tools.ts / Tool.ts / QueryEngine.ts — Modular agent architecture
In other words: this page is written in TypeScript, and so is the assistant that wrote it.
// Claude Code's Tool definition, roughly
interface Tool<Input, Output> {
name: string;
description: string;
inputSchema: JsonSchema<Input>;
handler: (input: Input) => Promise<Output>;
}
// Types fully describe a tool the LLM can call
// schema to the model, handler to the runtime
// TS keeps both sides in sync, alwaysAI tool chain · overwhelmingly TS
TS types ↔ AI interface
AI tools being written in TS is only the surface. Deeper: TS types are becoming an AI interface language in their own right.
OpenAI / Anthropic "function calling," Google "structured output," MCP tool definitions — all need a schema. Write that schema as a TS interface, validate at runtime with zod / arktype, hand it to LLMs via zod-to-json-schema. One type, three consumers: compiler, runtime, model.
Microsoft's TypeChat goes further: drop a TS interface into the prompt as a template, force the model to output that shape, retry on violation. An end-to-end pipeline from natural language to typed JSON.
// 1. Describe the desired output in TS
const Order = z.object({
customer: z.string(),
items: z.array(z.object({
sku: z.string(),
qty: z.number().int().positive()
})),
total: z.number()
});
// 2. Pass schema to the LLM
const order = await generateObject({
model: anthropic("claude-opus-4-7"),
schema: Order,
prompt: "User said: two cokes and a burger, please"
});
// 3. order is z.infer<typeof Order>
// Fully typed; auto-retry on schema violationSummary, one line: AI isn't TypeScript's competitor — it's the strongest ally TS has ever had. The more pervasive LLMs become, the more the world needs machine-readable code contracts. The "extra typing" TS asked for in the 2010s turned out to be the key to working with AI in the 2020s.
vs JavaScript : JS vs TS
Not replacement — superposition. But the things you can do after stacking types on top differ by orders of magnitude.
| JavaScript | TypeScript | |
|---|---|---|
| Type checking | Runtime only | Compile-time / live in IDE |
null / undefined | Bombs anywhere | Stripped from types under strict |
| Refactoring | Grep + prayer | Type-driven, one-click rename |
| Enums / unions | String constants on the honor system | enum / 'a' | 'b' | 'c' |
| Generics | None | <T>, with constraints and inference |
| 3rd-party types | Read docs / guess | @types/* or built-in .d.ts |
| Build output | Source itself | Plain JS after compile, zero runtime cost |
| Learning curve | Effectively zero | Gradual — start with any, tighten later |
| Cost at scale | Linear + snowballing bugs | Slightly higher up front, far lower after |
| AI collaboration | Hard to verify LLM output | Types as guardrails; 94% of LLM errors are type errors |
| Cross-platform contracts | Separate interface docs per platform | One .d.ts shared across platforms |
| IDE experience | JSDoc-patched, half-broken | Go-to / autocomplete / rename — the full set |
Outlook : TheRoadAhead
The compiler is going Go-native, runtimes are eating TS directly, and TC39 is trying to drag the syntax into the JS standard — three paths in motion at once.
Project Corsa / TypeScript 7
Anders Hejlsberg's team rewrites tsc in Go. The VS Code repo's type-check goes from 78s → 7.5s — Go's native compilation plus cross-module parallel type-checking. Microsoft calls it tsgo; it ships as TypeScript 7.0.
The deeper point: JS tooling has been bottlenecked by self-bootstrapping for years — the compiler written in JS, compiling itself. Switching to Go fixes the cold-start and memory issues in one stroke.
Type Annotations proposal
Add a rule to JS engines: treat type annotations as comments. Browsers and Node could then directly run TS-flavored code.
Status: Stage 1 of 4. Slow, contested, unlikely to land soon.
Runtimes that eat TS
Even without TC39, the major runtimes already work: Deno as first-class, Bun natively, Node.js 22+ with --experimental-strip-types. Once mainstream, the separate tsc step disappears.
78% of devs adopted
State of JS 2024: ~78% of respondents use TypeScript, more than half of them writing mostly TS rather than plain JS. Five years of straight growth.
New frameworks default to TS
Next.js, Nuxt, SvelteKit, SolidStart, Astro, Remix — every create template defaults to .ts. NestJS is TS-only. The "should we use TS for new projects?" debate is over.
AI era's inverse payoff
The "cost of types" used to fall on humans. With AI generating code, that cost shifts to the model — and humans move into reviewing / verifying / correcting. This amplifies the value of the type system: it gives humans a machine-readable guardrail.