What Is TypeScript & Why It Exists
TypeScript is a strongly-typed superset of JavaScript developed by Microsoft. Every valid JavaScript file is also a valid TypeScript file — TypeScript simply adds a static type layer on top. That type layer exists ONLY during development and compilation; it is completely erased in the output JavaScript. The browser and Node.js never see TypeScript types — they run plain JS.
TypeScript vs JavaScript — Core Difference
// ── JavaScript (no types — errors only at runtime) ────────────
function greet(name) {
return "Hello, " + name.toUpperCase();
}
greet(42); // 💥 Runtime crash: name.toUpperCase is not a function
// ── TypeScript (types enforced at compile time) ────────────────
function greet(name: string): string {
return "Hello, " + name.toUpperCase();
}
greet(42);
// ❌ Compile error: Argument of type 'number' is not assignable
// to parameter of type 'string'.
// → Caught BEFORE the code ever runs.
// ── Type Erasure — TypeScript disappears at runtime ────────────
// TypeScript source:
interface User {
id: number;
name: string;
}
const user: User = { id: 1, name: "Alice" };
// Compiled JavaScript output — the interface is GONE:
// const user = { id: 1, name: "Alice" };
//
// The runtime (browser / Node.js) has NO knowledge of `User`.
// This is why runtime validation (typeof, Zod) is necessary
// at boundaries like API responses and form inputs.Real-World Use Case
In a team of 10 engineers sharing a codebase, JavaScript gives you no signal that `processPayment(amount, currency)` exists — you must read the implementation or docs. TypeScript shows you the signature inline (`amount: number`, `currency: 'USD' | 'EUR'`), prevents you from passing the wrong type, and auto-completes field names. Studies show TypeScript catches ~15% of bugs before code review.
TypeScript = JavaScript + static types → fewer bugs, better tooling
Common Mistakes
- Thinking TypeScript makes JavaScript slower at runtime — it doesn't. TypeScript is removed at compile time; the output is identical-performance JavaScript.
- Using TypeScript without strict mode — most of its protection is disabled by default unless you add `"strict": true` to tsconfig.
- Treating TypeScript as a documentation tool only — its real value is compiler-enforced correctness, not just IDE hints.
Key Takeaways
- TypeScript is a strongly-typed superset of JavaScript developed by Microsoft.
- Thinking TypeScript makes JavaScript slower at runtime — it doesn't. TypeScript is removed at compile time; the output is identical-performance JavaScript.
- Using TypeScript without strict mode — most of its protection is disabled by default unless you add `"strict": true` to tsconfig.
- Treating TypeScript as a documentation tool only — its real value is compiler-enforced correctness, not just IDE hints.