What Is TypeScript
What is it?
Official: TypeScript is a strongly typed programming language that builds on JavaScript — created and maintained by Microsoft.
In plain words: TypeScript is JavaScript plus a type-checker that runs before your code does. You write almost-normal JS, add type annotations, and a compiler catches mistakes at build time instead of letting them blow up at runtime.
The one mental model
TypeScript is a compile-time layer. Every type you write is erased when the code is compiled to JavaScript — the browser or Node never sees a single type. So TS adds zero runtime behavior; it only checks your code and then gets out of the way.
let title: string = "hello";
Three things that define it
- Strongly typed. Values have types, and TypeScript refuses operations that don't make sense for them.
- A superset of JavaScript. Every valid
.jsfile is already valid TypeScript. You adopt it gradually — nothing to rewrite. - Not runnable by browsers directly. Browsers and Node don't understand TS. It must be compiled to JavaScript first (
tsc).
Errors show up at build time, not run time
This is the whole point. A type mistake still runs locally if you execute the emitted JS, but the build fails — so a broken deploy gets caught before it ships.
let count: number = 5;
count = "five"; // Error: Type 'string' is not assignable to type 'number'
TypeScript doesn't change what your program does — it changes when you find out it's wrong. Bugs move from a user's browser to your terminal.