This skill should be used when the user asks to "optimize TypeScript performance", "speed up tsc compilation", "configure tsconfig.json", "fix type errors", "improve async patterns", or encounters TS...
Comprehensive performance optimization guide for TypeScript applications. Contains 42 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Type System Performance | CRITICAL | type- |
| 2 | Compiler Configuration | CRITICAL | tscfg- |
| 3 | Async Patterns | HIGH | async- |
| 4 | Module Organization | HIGH | module- |
| 5 | Type Safety Patterns | MEDIUM-HIGH | safety- |
| 6 | Memory Management | MEDIUM | mem- |
| 7 | Runtime Optimization | LOW-MEDIUM | runtime- |
| 8 | Advanced Patterns | LOW | advanced- |
type-interfaces-over-intersections - Prefer interfaces over type intersections for faster resolutiontype-avoid-large-unions - Avoid unions with 12+ members (O(n²) checking)type-extract-conditional-types - Extract conditional types to enable cachingtype-limit-recursion-depth - Add depth limits to recursive typestype-explicit-return-types - Add explicit return types to exported functionstype-avoid-deep-generics - Flatten deeply nested generic hierarchiestype-simplify-mapped-types - Break complex mapped types into smaller utilitiestscfg-enable-incremental - Enable incremental compilation for 50-90% faster rebuildstscfg-skip-lib-check - Skip declaration file checking for 20-40% faster buildstscfg-isolate-modules - Enable single-file transpilation for bundler integrationtscfg-project-references - Split large codebases into independent projectstscfg-exclude-properly - Configure include/exclude to avoid scanning unnecessary filestscfg-strict-function-types - Enable strict mode for optimized variance checksasync-parallel-promises - Use Promise.all() for independent operationsasync-defer-await - Defer await until value is actually neededasync-avoid-loop-await - Avoid await inside loops, use Promise.all with mapasync-explicit-return-types - Annotate async function return typesasync-avoid-unnecessary-async - Skip async wrapper when just returning a Promisemodule-avoid-barrel-imports - Import directly from source, not barrel filesmodule-avoid-circular-dependencies - Extract shared types to break cyclesmodule-use-type-imports - Use type-only imports for typesmodule-dynamic-imports - Use dynamic import() for large modulesmodule-control-types-inclusion - Explicitly list @types packagessafety-prefer-unknown-over-any - Use unknown instead of any for safer handlingsafety-use-type-guards - Use type guards for runtime type checkingsafety-exhaustive-checks - Use never for exhaustive union handlingsafety-strict-null-checks - Enable strictNullChecks for null safetysafety-const-assertions - Use as const for literal type preservationsafety-assertion-functions - Use assertion functions for validationmem-use-weakmap-for-metadata - Use WeakMap for object metadatamem-avoid-closure-leaks - Extract only needed data in closuresmem-cleanup-event-listeners - Remove event listeners on cleanupmem-avoid-global-state - Use bounded caches, avoid unbounded globalsmem-clear-timers - Clear intervals and timeouts when doneruntime-use-set-for-lookups - Use Set/Map for O(1) lookupsruntime-cache-property-access - Cache property access in loopsruntime-avoid-object-spread-in-loops - Avoid spreading objects in hot loopsruntime-use-for-of-for-iteration - Use for-of for clean array iterationruntime-prefer-array-methods - Prefer native array methods over lodashruntime-use-string-methods - Use modern string methods (startsWith, includes)advanced-branded-types - Use branded types for type-safe IDsadvanced-template-literal-types - Use template literals for string patternsadvanced-satisfies-operator - Use satisfies for validation with inferenceRead individual reference files for detailed explanations and code examples:
For the complete guide with all rules expanded: AGENTS.md