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 hereAll lessons in this course
- Profiling Slow TypeScript Compilation
- Avoiding Expensive Type Operations
- skipLibCheck and Isolated Declarations
- Type-Checking in CI: Strategies and Tools