From harness-claude
Optimizes TypeScript compilation time and reduces type complexity using incremental builds, skipLibCheck, project references, simplified generics, and tsconfig tweaks. For slow builds, IDE lag, or deep type errors.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Reduce TypeScript compilation time and type complexity with targeted optimizations
Optimizes TypeScript performance via 45 rules on type system, compiler config (tsconfig.json), async patterns, modules, memory management. Fixes type errors, speeds tsc.
Provides TypeScript and JavaScript expertise in type-level programming, performance optimization, monorepo management, migration strategies, and modern tooling.
Provides tsconfig.json patterns for extends, project references, composite builds, and incremental compilation. Use for monorepo setups, new TypeScript projects, or troubleshooting compilation issues.
Share bugs, ideas, or general feedback.
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