From harness-claude
Optimizes TypeScript compilation speed and type complexity with techniques like incremental builds, skipLibCheck, project references, and simplified generics.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:ts-performance-patternsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Reduce TypeScript compilation time and type complexity with targeted optimizations
Reduce TypeScript compilation time and type complexity with targeted optimizations
{
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": ".tsbuildinfo"
}
}
skipLibCheck to skip type-checking .d.ts files:{ "compilerOptions": { "skipLibCheck": true } }
This is the single biggest compilation speed improvement for most projects.
{ "references": [{ "path": "packages/a" }, { "path": "packages/b" }] }
Build with tsc --build for dependency-aware parallel compilation.
// Slow: deeply nested inline generics
type Bad = Map<string, Array<Promise<Result<Map<string, Set<number>>>>>>;
// Fast: named intermediates
type NumberSets = Map<string, Set<number>>;
type ResultPromises = Array<Promise<Result<NumberSets>>>;
type Good = Map<string, ResultPromises>;
// Can cause "type instantiation excessively deep" errors
type DeepPartial<T> = {
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
};
// Add a depth limiter
type DeepPartial<T, D extends number = 5> = D extends 0
? T
: { [K in keyof T]?: T[K] extends object ? DeepPartial<T[K], Prev[D]> : T[K] };
type Prev = [never, 0, 1, 2, 3, 4, 5];
// Faster — interface declaration is cached by name
interface User {
id: string;
name: string;
email: string;
}
// Slower — type alias is re-evaluated each time it's referenced
type User = { id: string; name: string; email: string };
// Slow: 50-member union
type Event = EventA | EventB | EventC | ... | EventAX;
// Faster: grouped unions
type UserEvent = UserCreated | UserUpdated | UserDeleted;
type OrderEvent = OrderPlaced | OrderShipped | OrderCancelled;
type Event = UserEvent | OrderEvent;
isolatedModules for fast single-file transpilation with esbuild or swc:{ "compilerOptions": { "isolatedModules": true } }
{
"include": ["src"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.stories.ts"]
}
tsc --generateTrace ./trace
# Open chrome://tracing and load the trace JSON
TypeScript's type-checker is a constraint solver that runs at compile time. Complex types (deep generics, large unions, recursive mapped types) can cause exponential computation.
Common performance killers:
infer chains@ts-ignore on incorrect code (the checker still processes it)Interface vs type alias performance: Interfaces create named cached entries in the type checker. When the same interface is referenced multiple times, the checker reuses the cached result. Type aliases with intersection types (A & B & C) must be re-flattened at each use site.
skipLibCheck justification: Third-party .d.ts files rarely change between builds, and their type errors are not actionable by your team. Skipping them saves 20-40% of compilation time on typical projects.
Project references trade-offs:
composite: true requirement, declaration files must be generatedMeasuring improvement: Run tsc --noEmit --diagnostics to see check time, program size, and memory usage. Compare before and after optimizations.
https://typescriptlang.org/docs/handbook/performance.html
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeConfigures tsconfig.json with extends, project references, composite builds, incremental compilation, and separation of concerns for monorepos and build optimization.
Provides advanced TypeScript/JavaScript expertise for type-level programming, performance optimization, monorepo management, migrations, and modern tooling. Analyzes projects, applies fixes, and validates with typechecks/tests.
TypeScript deep-dive skill covering type-level programming, performance optimization, monorepo patterns, and migration strategies. Also redirects to specialized subagents for bundler/module/type issues.