Course contentsShow
← TypeScript
Lesson 1235 of 1,79629. The Build PipelineFree lesson

Type-Checking vs Transpilation Separation

Learn why many bundlers only strip types without checking them, leaving validation to a separate step.

Type-Checking vs Transpilation Separation

What you'll learn: Why modern bundlers strip TypeScript types without validating them, leaving type-checking as a separate responsibility.

The Two Jobs TypeScript Does

When you run tsc, TypeScript performs two distinct operations:

  1. Type-checking: Analyzing your code for type errors, ensuring everything matches up correctly
  2. Transpilation: Converting TypeScript syntax (especially type annotations) into JavaScript

Historically, these happened together. Run tsc, get both safety checks and executable JavaScript.

The Modern Split

Many modern bundlers (like esbuild, Vite, and SWC) take a different approach: they only strip types. They literally delete type annotations to produce JavaScript, without checking if those types were correct.

Why This Separation Exists

Think of it like spell-check vs printing. You can print a document without spell-checking it first — the printer doesn't care about typos. Similarly, bundlers can produce working JavaScript without verifying type correctness.

Performance is the main driver: Type-checking is computationally expensive. Stripping types is trivial — it's just deleting syntax. By skipping validation, bundlers achieve speeds 10-100x faster than tsc.

The Two-Step Workflow

In this model, you run two separate commands:

  1. Fast transpilation (bundler): vite build or esbuild src/index.ts — produces JavaScript quickly
  2. Separate validation (TypeScript): tsc --noEmit — checks types without outputting files

This separation lets you iterate rapidly during development while still maintaining type safety through CI checks or pre-commit hooks.

The Trade-off

The downside? Your build might succeed even with type errors. You must remember to run type-checking separately, or broken code could ship.

Key Takeaway: Modern bundlers separate transpilation (fast, strips types) from type-checking (slower, validates correctness), giving you speed during builds but requiring a separate validation step for safety.