Camp 1 · Step 1 of 13
Why TypeScript?
What types buy you, why half the JavaScript world switched, and what TypeScript actually is.
TypeScript is JavaScript with a safety net. Same language, same syntax, same everywhere-it-runs — plus a system of types that catches a huge class of bugs before your code ever runs.
The bug types prevent
Every JavaScript developer has shipped this bug:
function greet(user) {
return "Hello, " + user.name.toUpperCase();
}
greet("Ada"); // 💥 TypeError at runtime: user.name is undefinedJavaScript happily accepts the call and explodes later, in production, at 2 a.m. TypeScript refuses at compile time:
function greet(user: { name: string }) {
return "Hello, " + user.name.toUpperCase();
}
greet("Ada");
// ❌ Error: Argument of type 'string' is not assignable
// to parameter of type '{ name: string }'The mistake is caught while you type it — in your editor, with a red squiggle, seconds after writing it. That feedback loop is why TypeScript took over: it powers VS Code, Angular, and most large JavaScript codebases.
What TypeScript actually is
- A superset of JavaScript: every valid JS program is valid TS
- Types are erased at build time — browsers run plain JavaScript
- Created at Microsoft (2012), open source, now everywhere
Try it — this playground compiles and runs real TypeScript:
When does TypeScript catch type errors?
What's next
We take working JavaScript and add types to it, one annotation at a time.