0Pricing
TypeScript Academy · Lesson

Profiling Slow TypeScript Compilation

Use --extendedDiagnostics and --generateTrace to find bottlenecks.

Why TypeScript Can Be Slow

Complex conditional types, large union distributions, and deeply recursive mapped types can cause TypeScript's type checker to slow dramatically on big projects.

// Expensive: distributive conditional on large union
type Slow = LargeUnion extends infer T ? T extends string ? T : never : never;

--extendedDiagnostics Flag

Run tsc --extendedDiagnostics to see a breakdown of compilation time: parsing, binding, type checking, and emit phases.

tsc --extendedDiagnostics 2>&1 | head -40
# Output:
# Files:             212
# Lines:            48320
# Check time:       8.23s  ← focus here

All lessons in this course

  1. Profiling Slow TypeScript Compilation
  2. Avoiding Expensive Type Operations
  3. skipLibCheck and Isolated Declarations
  4. Type-Checking in CI: Strategies and Tools
← Back to TypeScript Academy