Performance
Diagnose
- Latest version for TypeScript, dependencies, editor, plugins and extensions.
- Disable all editor extensions.
- No other hogging resources.
- Use strict compilation.
Fixing TypeScript performance problems:
tsc --listFilesOnly
tsc --explainFiles > explanations.md
tsc --extendedDiagnostics
tsc --generateTrace <output_dir>
node --max-old-space-size=8192 ./node_modules/.bin/tsc -b --extendedDiagnostics --generateTrace ./ts-trace
pnpm dlx analyze-trace ./ts-trace
Compiler
- Faster tools:
swc/rome. - Multithread:
ts-loader+fork-ts-checker-plugin. - Project references (
tsc -bbuild mode):- Find
tsconfigreferenced projects. - Detect if they are up-to-date.
- Build out-of-date projects in correct order.
- Build provided
tsconfigif itself or any dependencies have changed.
- Find
- Skip type checking (sometimes).
- Load
@types/by need (include/exclude/compilerOptions.types). tsc --listFiles列出编译时包含文件列表,tsc --traceResolution列出编译时包含文件原因.