TS Intro
TypeScript is JavaScript with an opt-in static type system. You write .ts, the compiler checks the types, and it emits plain .js that runs anywhere JS runs.
Why bother
- Catches bugs at compile time — missing properties, wrong types, typos.
- IDE superpowers — accurate autocomplete, refactors, find-references.
- Self-documenting — signatures show intent;
anyis the new "TODO". - Refactor with confidence — rename a field; the type checker finds every consumer.
- Big-team friendly — types are a contract between modules.
How it relates to JavaScript
| TS feature | What happens at runtime |
|---|---|
Type annotations (: string) | Erased — gone. |
| Type aliases / interfaces | Erased. |
| Generics | Erased. |
| Enums | Compile to a JS object. |
| Classes | Compile to JS classes. |
| Decorators | Compile to function calls. |
Who uses it
Most large JavaScript codebases — VS Code, Slack, Airbnb, Microsoft Office, Notion, Vercel, every modern frontend framework's docs and source. State-of-JavaScript-2024 says ~78% of professional JS devs reach for TS by default.
The TypeScript you're learning
This tutorial targets TypeScript 5.x: satisfies, the const type parameter, decorators (stage 3), using for resource disposal, faster build modes. Modern patterns first; legacy syntax flagged where you'll still see it.
Tip: The TS team's slogan is "JavaScript that scales". If your project is a single small file you'll get away with plain JS. The moment a second person touches the code, types start paying for themselves.
Example
Example
// TypeScript adds types on top of JavaScript.
const name: string = 'Ada';
const age: number = 36;
console.log(`${name} is ${age}`);
Try it Yourself »
Exercise
TypeScript is a static…
system on top of JavaScript
Four letters.
Discussion
Loading…