$ recombobulate _
home / tips / use-claude-to-fix-typescript-strict-mode-violations
71

Use Claude to Fix TypeScript Strict Mode Violations

recombobulate @recombobulate · Mar 25, 2026 · Debugging
use-claude-to-fix-typescript-strict-mode-violations

Enabling "strict": true in tsconfig.json often unleashes hundreds of errors at once — paste them in batches and let Claude work through them systematically rather than one agonising error at a time.

# Get your full error list first
npx tsc --noEmit 2>&1 | head -100 | claude -p "Fix all these TypeScript strict mode violations. For each one, explain the root cause and show the corrected code."

Rather than wrestling with cryptic messages, Claude explains the root cause and applies the right fix — whether that's adding type guards, replacing any with meaningful types, or handling possibly-null access:

// Before (strict mode violation — Object is possibly 'undefined')
function getUser(id: string) {
  const user = users.find(u => u.id === id);
  return user.name;
}

// After (Claude's fix)
function getUser(id: string): string {
  const user = users.find(u => u.id === id);
  if (!user) throw new Error(`User ${id} not found`);
  return user.name;
}

For any types specifically, ask Claude to infer proper types from how the variable is actually used throughout your codebase — it's far more accurate than guessing manually.

You can also ask Claude to enable strict mode incrementally: turn on one flag at a time (like noImplicitAny first, then strictNullChecks) and fix each batch before moving on.

Strict mode is painful to enable on existing codebases — Claude turns a multi-week migration into an afternoon.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
161
Ask Claude to Find and Fix the Performance Bottleneck in a Slow Endpoint

When a page takes five seconds to load or an API endpoint times out under load, tell Claude which route is slow and it traces the entire code path — controller, services, queries, loops — identifying N+1 queries, redundant computations, missing indexes, and cacheable operations, then fixes each bottleneck.

recombobulate @recombobulate · 1 month ago
149
Ask Claude to Diagnose and Fix Flaky Tests That Pass Sometimes and Fail Randomly

Flaky tests are maddening — they pass locally, fail in CI, pass again when you retry. Tell Claude to read the test, identify the source of non-determinism — timing issues, shared state, date dependencies, or order-dependent setup — and fix the root cause so the test is reliably green or reliably red.

recombobulate @recombobulate · 1 month ago
148
Paste an Error Message or Stack Trace and Let Claude Trace It to the Root Cause

When your app throws an error, don't just Google the message — paste the full stack trace into Claude Code. It reads the trace, opens the referenced files in your codebase, follows the call chain, and pinpoints the actual root cause instead of just explaining the symptom.

recombobulate @recombobulate · 1 month ago