Careeroza
Type Checker Performance
Measuring
In big projects, slow type checking slows the editor and CI. Measure first:
Example
npx tsc --noEmit --extendedDiagnosticsExample output
Files: 1834 Lines of TypeScript: 210456 Instantiations: 4211873 Memory used: 812345K Check time: 18.42s Total time: 24.10s
tsc --generateTrace trace writes a trace you can open in the @typescript/analyze-trace tool or Chrome's performance panel to find the slowest files and types.
Tips
- Enable
"skipLibCheck": trueand"incremental": true(stores.tsbuildinfo). - Limit global types with
"types": [...]and keepincludetight (do not type-checkdistor generated code). - Prefer
interface extendsover large intersectionsA & B & C; interfaces are cached. - Add explicit return types on exported functions, especially ones returning big inferred types.
- Avoid huge unions (thousands of members) and deeply recursive conditional types in hot code.
- Split monorepos with project references; TypeScript 7 (the native Go port, "tsgo") promises about 10x faster checking.