Things Have History
TypeScript, or how JavaScript learned to say what it meant

programming-languages

TypeScript, or how JavaScript learned to say what it meant

Listen · 3:55

Anders Hejlsberg had already designed three programming languages by 2010 — Turbo Pascal at twenty-two, Delphi at Borland, C# at Microsoft — and all three shared the same conviction: you should declare what a variable holds, and the compiler should tell you when you are wrong. Then, sometime around 2009, he looked at what was actually running the web. JavaScript had been written in ten days in 1995 and deployed everywhere. It had no type declarations whatsoever.

The problem was scale. Microsoft’s own teams were building Bing and Office 365 in JavaScript, with hundreds of engineers working in codebases large enough that no single person could hold the whole thing in mind. In a typed language, the compiler plays the colleague who has read every line of code; in JavaScript, type errors surfaced at runtime — which, in production software, meant in front of users. Hejlsberg’s solution, codenamed Strada inside Microsoft, was not to replace JavaScript but to extend it: add optional type annotations, compile them away, and produce ordinary JavaScript that any browser could run. The types were training wheels that disappeared before the race.

TypeScript 0.8 launched publicly on October 1, 2012, with Hejlsberg presenting it on Microsoft’s Channel 9 video platform. The JavaScript community’s response was immediate and skeptical. To developers who had argued for years that dynamic typing was a feature, not a bug, the announcement sounded — as the team later acknowledged — like “an evil plot or a joke.” Google had the Closure Compiler; Facebook was building Flow. TypeScript’s key design choice was structural typing: if an object has the right shape, it is the right type, regardless of what class it came from. This made TypeScript feel like JavaScript rather than like a committee’s idea of what JavaScript should become.

Four days after the launch — October 5, 2012 — a developer named Boris Yankov created a GitHub repository called DefinitelyTyped. Yankov’s logic was blunt: thousands of JavaScript libraries existed and had never heard of TypeScript. Someone had to write type definitions for them. He started with the libraries he was already using, reading source code to reverse-engineer the type signatures. Within months, dozens of contributors had added definitions for jQuery, Node.js, and Backbone. DefinitelyTyped became the community’s project for retrofitting types onto an ecosystem that had never asked for them.

The tipping point came in 2015, when Google announced that Angular 2 would be written in TypeScript and would recommend TypeScript for applications built with it. A language that had looked like a Microsoft experiment was now backed by Google’s largest open-source project. By the early 2020s, annual developer surveys consistently ranked TypeScript among the most-loved languages in the industry — a category it had not been expected to compete in when Hejlsberg unveiled it a decade earlier.

Hejlsberg’s bet, the one Strada had carried since 2009, was that types don’t constrain a program — they describe it clearly enough that a compiler can help. Every major JavaScript framework that shipped after 2015 arrived with TypeScript definitions either built in or available the same day. The annotation and the code had become the same thing.

Sources

Spot a mistake?

Wrong date, broken citation, a fact that doesn't hold? Tell us. It lands in an inbox a human reads and the post can be pulled or corrected.