Fix TypeScript Errors
Steps
- •
Run typecheck to get current errors:
- •Monorepo (pnpm-workspace.yaml exists):
pnpm type-checkorpnpm typecheck - •Standard project:
npm run typecheckornpm run type-check - •Fallback:
npx tsc --noEmit
- •Monorepo (pnpm-workspace.yaml exists):
- •
Parse the output — group errors by file
- •
Fix each error by reading the file, understanding context, and applying the minimal correct fix:
- •Missing types → add them (derive from schema if available, never define separately)
- •Wrong types → correct them
- •Missing imports → add them
- •Null/undefined → add proper checks (not
!assertions unless truly safe) - •Generic type args → infer from usage
- •
Re-run typecheck to confirm zero errors
- •
Report what was fixed:
codeFixed N type errors: - file:line — what was wrong → what was fixed
Rules
- •Never use
anyunless absolutely unavoidable (explain why) - •Never use
@ts-ignoreor@ts-expect-errorto suppress errors - •Derive types from schemas (Zod, Drizzle, Prisma) — never define separately
- •If a fix requires an architectural decision, stop and ask