Type Doctor diagnoses potential TypeScript performance issues by analyzing type checking traces.
Type Doctor analyzes TypeScript trace files to identify expressions that take too long to type-check. It helps you find performance bottlenecks in your TypeScript codebase by pinpointing slow type checking operations.
bun installBuild the CLI:
bun run buildFirst, generate a trace file from your TypeScript project:
tsc --generateTrace trace.jsonAnalyze a trace file:
bun cmd/cli.ts trace.jsonOr use the compiled binary:
./bin/td trace.json--checkTimeMsWarn <ms>: Set the warning threshold in milliseconds for a single expression check (default:500)--checkTimeMsError <ms>: Set the error threshold in milliseconds for a single expression check (default:1000). Must be greater thancheckTimeMsWarn-a, --annotate: Enable GitHub Actions annotations (also enabled automatically in CI)-d, --debug: Enable debug logging-h, --help: Show help message
Analyze with a custom error threshold:
bun cmd/cli.ts --checkTimeMsError 50 trace.jsonAnalyze with custom warning and error thresholds:
bun cmd/cli.ts --checkTimeMsWarn 200 --checkTimeMsError 500 trace.jsonEnable GitHub Actions annotations:
bun cmd/cli.ts -a trace.jsonEnable debug logging:
bun cmd/cli.ts -d trace.json- Bun runtime
- TypeScript 5.x (peer dependency)
- A
tsconfig.jsonfile in your project root
# Install dependencies
bun install
# Build the CLI
bun run build
# Run tests (if available)
bun test