Why TypeScript
TypeScript is JavaScript with a type checker bolted on at compile time. Every valid JavaScript program is (almost) valid TypeScript — the type checker just refuses to compile the ones it can prove are wrong before they run. Assign a string where a function expects a number, call a method that does not exist on an object, forget to handle the null case — TypeScript catches all three while you type, not when a user does.
It compiles down to plain JavaScript — the types are erased, not shipped. There is no "TypeScript runtime"; there is a compiler (tsc) that reads your .ts files, checks the types, strips them, and writes out .js. That is also why a type error is never something a user sees: it either stops the build, or your team ships it anyway and the type checker did its job for nothing. This handbook is about the first kind of team.
- Catches bugs before runtime — a typo in a property name, a function called with the wrong argument order, forgetting a case in a switch.
- Autocomplete that is actually correct — your editor knows the exact shape of every object, because the compiler does.
- Safe refactoring — rename a field and the compiler lists every call site that breaks, instead of you finding them in production.
- The de facto standard — React, Node, Angular, most serious open-source libraries ship TypeScript types; most job listings for "JavaScript" now mean this.
this, the event loop, prototypes, all of it. This handbook does not repeat that; it teaches the layer TypeScript adds on top. If a run block here confuses you at the JavaScript level, that lesson is the one to read first.