Build failed: Type error (passes in dev, fails in next build)
Failed to compile. Type error: Property 'x' does not exist on type 'y'.
In short: Dev mode is lenient about types; production builds run the type checker and stop on errors.
Why it happens
next dev and Vite dev servers transpile without full type checking, so errors only appear when the host runs the build. AI edits often change a type in one file without updating callers.
How to fix it
- Reproduce locally:
npm run build(ornpx tsc --noEmit). - Fix errors from the top. Later ones are often consequences of the first.
- Type API responses and props instead of using
anyto hide them. - Run the build before every push, or add it to CI.
Copy-paste fix prompt
I'm getting this error in my app: Failed to compile. Type error: Property 'x' does not exist on type 'y'. [Paste the full error, stack trace, and the file it points to here] Likely cause: Dev mode is lenient about types; production builds run the type checker and stop on errors. Task: Run the type checker, group the errors by root cause, and fix the root causes with correct types, without any, ts-ignore, or disabling build checks. Rules: - First explain the root cause in 2 sentences and list the files you'll change. - Make the smallest change that fixes it. Don't refactor unrelated code. - Don't disable security or checks (RLS, auth, signature verification, type checking, CORS allow-all) to make the error disappear. - Never print or hard-code secret keys. - Finish by telling me exactly how to verify the fix.
Common with: Cursor, v0, Claude Code, Bolt. Last reviewed 2026-11-13.