What is TypeScript?
TypeScript is JavaScript with a shape-checker bolted on, so wrong pieces never fit.
Mental model
Plain English
TypeScript adds labels to your code that say 'this value must be a string', 'this object must have these fields'. Before the app runs, a checker confirms everything fits. Most bugs caught by TypeScript are 'you passed the wrong shape'.
JavaScript is IKEA furniture with no labels. TypeScript adds the part numbers so you can't put a leg in a screw hole.
type Task = { title: string; dueDate: string; weddingId: string }. If you forget dueDate when calling createTask, TypeScript yells before the app runs.
type Conversation = { id: string; channel: 'whatsapp' | 'instagram' | 'email' }. Any other channel is rejected.
Go deeper
JavaScript with a part-number checker.
Common mistakes
- Using 'any' everywhere to silence the checker. That defeats the point.
- Trusting types alone — TS doesn't catch logic bugs, only shape bugs.
AI-agent trap
Summary
You write types alongside your code. The compiler checks them at build time. If a function expects { title: string } and you pass { title: 123 }, you get an error before you run.