Skip to main content

Beginner-Friendly Topic

Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!

Lesson 1 of 9

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.

10 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

TypeScript vs JavaScript - Core Difference

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.

Diagram
Loading diagram…

Visual architecture and concepts for What Is TypeScript & Why It Exists

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.

Finished this lesson?

0 of 9 in Module 1
Sign in to save progress

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/9 done