compiler-performance
Pay Attention to Compiler Performance
Overview
TypeScript compilation can become slow in large projects. Monitor and optimize compiler performance using techniques like project references, proper tsconfig settings, and avoiding expensive type patterns. Fast compilation improves developer experience.
When to Use This Skill
- Build times are slow
- Optimizing TypeScript projects
- Configuring project references
- Working with large codebases
- Improving IDE responsiveness
The Iron Rule
Monitor and optimize TypeScript performance. Use project references, avoid expensive type patterns, and keep compilation fast.
Performance Tips
// AVOID: Expensive recursive types
type DeepPartial<T> = T extends object
? { [K in keyof T]?: DeepPartial<T[K]> }
: T;
// PREFER: Iterative approaches, project references
// Split large projects using project references
// tsconfig.json optimizations
{
"compilerOptions": {
"incremental": true, // Incremental compilation
"tsBuildInfoFile": ".tsbuildinfo"
}
}
Reference
- Effective TypeScript, 2nd Edition by Dan Vanderkam
- Item 78: Pay Attention to Compiler Performance
More from marius-townhouse/effective-typescript-skills
precise-any-variants
Use when forced to use any. Use when any is too broad. Use when function types need any.
86narrow-any-scope
Use when any is unavoidable. Use when working with untyped libraries. Use when silencing specific type errors.
35tsdoc-comments
Use when documenting public APIs. Use when writing library code. Use when using JSDoc-style comments. Use when generating documentation. Use when explaining complex types.
33exhaustiveness-checking
Use when handling tagged unions. Use when adding new cases to discriminated unions. Use when switch statements must cover all cases.
13code-gen-independent
Use when confused about types at runtime. Use when trying to use instanceof with interfaces. Use when type errors don't prevent JavaScript output.
12tsconfig-options
Use when setting up a TypeScript project. Use when confused by type checking behavior. Use when strict mode causes unexpected errors.
11