Using --extendedDiagnostics for Build Metrics
You'll learn how to enable TypeScript's extended diagnostics flag to get detailed timing breakdowns of your compilation process, helping you identify performance bottlenecks.
What Are Extended Diagnostics?
When you run the TypeScript compiler, it performs dozens of internal operations—reading files, parsing syntax, checking types, resolving modules, and more. By default, these operations happen invisibly. The --extendedDiagnostics flag lifts this curtain, exposing exactly how long each phase takes and how much memory the compiler uses.
Think of it like adding a detailed speedometer and fuel gauge to your car engine. You can see exactly which cylinders are working hardest and where the power is being consumed.
How to Enable Extended Diagnostics
You enable this flag directly from the command line:
tsc --extendedDiagnostics
Or combine it with other compilation tasks:
tsc --noEmit --extendedDiagnostics
You typically wouldn't add this to your tsconfig.json because it's a diagnostic tool for investigation, not everyday builds.
What You'll See
When you run with --extendedDiagnostics, the compiler outputs detailed metrics at the end of compilation:
- Files: Total files analyzed
- Lines of code: Across all files
- Identifiers: Number of symbols tracked
- Symbols: Type system entities
- Types: Unique types created
- Instantiations: How many times generic types were instantiated
- Time in each phase: Parse time, bind time, check time, emit time
- I/O operations: Time spent reading and writing
- Memory usage: Peak memory consumed
Each timing breakdown shows you where the compiler is spending its cycles—whether it's struggling with type checking, file I/O, or code generation.
When to Use This Flag
Use --extendedDiagnostics when:
- Your builds feel slow and you need to know why
- You're optimizing a large codebase
- You've made type system changes and want to measure impact
- You're debugging excessive memory usage
- You're comparing performance before and after refactors
The metrics give you objective data to guide optimization efforts rather than guessing which changes will help.
Key Takeaway: The --extendedDiagnostics flag reveals detailed timing and memory metrics for each compilation phase, turning the TypeScript compiler into a transparent performance profiler that helps you identify and fix build bottlenecks.