ts-repair is an oracle-guided repair engine that turns TypeScript diagnostics into verified repair plans. Every fix is proven to reduce errors before your agent sees it.
$ npm install -g ts-repair Get verified TypeScript repairs in under a minute.
npm install -g ts-repair ts-repair repair ./tsconfig.json ts-repair repair --apply Add to your agent's MCP configuration for automatic TypeScript repair integration.
{
"mcpServers": {
"ts-repair": {
"command": "bunx",
"args": ["ts-repair", "mcp-server"]
}
}
} Instead of giving agents raw errors and hoping they fix them, ts-repair speculatively applies every candidate fix, re-runs the type checker, and only surfaces fixes that provably reduce errors.
No heuristics. No LLM guessing. The actual type checker that will judge your code is the same one verifying the fixes. That's why every fix in a repair plan is guaranteed to help.
ts-repair verifies which TypeScript fixes actually help and rejects those that introduce new errors.
Auto-add imports for undefined symbols from your project or dependencies.
Add missing async or await modifiers to functions and calls.
Rename misspelled identifiers to matching names in scope.
Add missing properties to objects and interfaces.
Clean up unused imports, variables, and parameters.
Add .js extensions to module imports for ESM compatibility.
Plus ~73 other fix types from TypeScript's Language Service, each verified before being surfaced.
Claude Code fixing TypeScript errors in Zod v4 — with and without ts-repair.
Early results from a single benchmark. We seeded 206 type errors into Zod v4 and measured Claude Code's repair process. Results will vary by project complexity and error types. Full methodology →
ts-repair treats the TypeScript compiler as a verification oracle.
while diagnostics > 0:
for each diagnostic, get candidate fixes
for each candidate:
apply to in-memory copy
re-run type checker
measure delta (errors removed - errors introduced)
select best candidate (max delta)
commit and repeat For each diagnostic, ts-repair generates candidate fixes (from TypeScript's Language Service and custom repair recipes), applies each to an in-memory copy, re-runs the type checker, and measures the exact delta. Only fixes that provably help are included in the plan.
{
"status": "12 diagnostics → 0 diagnostics",
"confidence": "verified",
"steps": [
{
"action": "Add missing import",
"resolves": 7,
"file": "src/api.ts",
"change": "import { User } from './types'"
},
{
"action": "Fix argument type",
"resolves": 3,
"file": "src/handlers.ts"
},
{
"action": "Add null check",
"resolves": 2,
"file": "src/utils.ts"
}
]
} In-memory snapshots for speculative evaluation
Language Service for diagnostics and candidate fixes
Greedy selection with solver fallback for conflicts
Labels each diagnostic by disposition
Smart scope management keeps verification bounded for structural edits
Production-ready with telemetry and resource management
After verification, each remaining diagnostic is classified so agents know exactly what to do.
Verified fix exists and is safe to auto-apply. Add imports, fix typos, add async/await.
Verified fix exists but involves type assertions or coercions. Opt-in to apply.
Multiple verified fixes with comparable scores. Surface ranked options to the agent or human.
TypeScript has no suggested fix for this diagnostic. Manual investigation needed.
Fixes exist but none reduce errors. Indicates a root cause elsewhere that needs investigation.
{
"remaining": [
{
"diagnostic": "TS2304: Cannot find name 'foo'",
"disposition": "AutoFixable",
"risk": "low"
},
{
"diagnostic": "TS2352: Type assertion required",
"disposition": "AutoFixableHighRisk",
"risk": "high"
},
{
"diagnostic": "TS2345: Argument type mismatch...",
"disposition": "NeedsJudgment",
"candidates": 3
},
{
"diagnostic": "TS2339: Property does not exist...",
"disposition": "NoGeneratedCandidate",
"note": "No TypeScript fix available"
},
{
"diagnostic": "TS2322: Type mismatch...",
"disposition": "NoVerifiedCandidate",
"note": "Fixes exist but none reduce errors"
}
]
} Every fix in the plan is proven by the TypeScript compiler to reduce errors. No heuristics.
Each committed fix reduces the diagnostic count. No fix that introduces more errors than it resolves.
Same input yields the same repair plan. No randomness, no heuristics that vary by run.
ts-repair integrates with AI coding assistants via the Model Context Protocol (MCP).
Generate a verified TypeScript repair plan
Apply verified repairs to files
Quick check for TypeScript error count
{
"mcpServers": {
"ts-repair": {
"command": "bunx",
"args": ["ts-repair", "mcp-server"]
}
}
} {
"mcp": {
"ts-repair": {
"type": "local",
"command": ["bunx", "ts-repair", "mcp-server"],
"enabled": true
}
}
} [mcp_servers.ts-repair]
command = "bunx"
args = ["ts-repair", "mcp-server"]
enabled = true Key commands for repair planning and application.
ts-repair repair -p tsconfig.json
ts-repair repair --apply
ts-repair repair --json Generate a verified repair plan with optional auto-apply.
ts-repair plan -p tsconfig.json --format json Generate a repair plan without mutating the workspace.
ts-repair apply -p tsconfig.json --auto
ts-repair apply --plan plan.json Apply verified repairs from a plan or auto-fix low-risk issues.
ts-repair check -p tsconfig.json
Equivalent to tsc --noEmit. Quick error count.
Scoring strategies: --scoring-strategy delta (default) or weighted for nuanced repairs.
Full CLI reference →
Integrate ts-repair directly into your tooling, CI pipelines, or custom workflows.
import { repair } from 'ts-repair';
const plan = await repair({
project: './tsconfig.json',
maxCandidates: 10,
maxVerifications: 500,
});
console.log(`${plan.initialErrors} → ${plan.finalErrors} errors`);
for (const step of plan.steps) {
console.log(`Apply: ${step.fixDescription}`);
} await repair({
project: './tsconfig.json',
// Max candidates per diagnostic
maxCandidates: 10,
// Max candidates per iteration
maxCandidatesPerIteration: 100,
// Verification budget
maxVerifications: 500,
// Include high-risk fixes (type assertions)
includeHighRisk: false,
// Scoring: 'delta' or 'weighted'
scoringStrategy: 'delta',
}); maxCandidates — Limit candidates per diagnostic
maxVerifications — Total verification budget
includeHighRisk — Include type assertions (opt-in)
scoringStrategy — 'delta' or 'weighted'
ts-repair is under active development for TypeScript. Here's what's on the roadmap.
Rust, Go, and Python support using the same oracle-guided approach.
Formal specification for language-agnostic repair integration.
Learn scoring weights from historical fix success data.