Your AI coding agent broke the Next.js build with a TypeScript error, and turned off type checking to hide it

next build fails on TypeScript errors your AI agent never ran into. Here is why, why ignoreBuildErrors only hides the problem, and how to find and fix the real error with tsc.

מעבר לתיקון
בעמוד הזה

Your AI coding agent says the feature is done. You push, the deploy fails, and the log ends with “Failed to compile” and a TypeScript error in a file you did not touch. Often the agent’s next move is to open next.config.js and turn the check off. Do not let it.

The error is real, and switching the check off only moves the crash from your build to your users.

Why this happens

The Next.js docs for the typescript option say that Next.js fails your production build (next build) when TypeScript errors are present in your project. That is the default: ignoreBuildErrors is false.

Agents hit this because they write code and run it, but rarely run the type check over the whole project. A change in one file can break the types in another, and nothing complains until the production build runs the check across everything.

The shortcut an agent reaches for is this:

// next.config.js
module.exports = {
  typescript: {
    ignoreBuildErrors: true,
  },
}

The docs are blunt about it. This does not run TypeScript and hide the errors, it bypasses the check entirely, and the docs call the result dangerous unless you type check somewhere else in your build or deploy process. The deploy goes green and the type error is still in your code.

How to find the real error

  1. Read the first error in the build log, not the last. Later errors are often knock-on effects of the first one.
  2. Reproduce it locally by running the same check the build runs: npx tsc --noEmit. It prints every type error in the project without writing any files.
  3. Open the file and line it names. Check what the agent changed recently in the types, props, or function signatures that file depends on.

The fix

Fix the type, not the check. Typical agent-made mistakes are a prop renamed in one component but not at its call sites, a function that now returns string | undefined where the caller expects string, or an any replaced with a type that is too narrow.

Ask the agent for something specific:

Run npx tsc --noEmit, fix every error without using any, @ts-ignore, or ignoreBuildErrors, and show me the final output.

Then run npx tsc --noEmit yourself and confirm it exits with no errors before you push.

If you really must ship with a known error, leave ignoreBuildErrors off and use a targeted // @ts-expect-error with a comment on the one line. It fails loudly on its own the day the error is fixed, so it cannot linger unnoticed.

Keep it from coming back

Add the check to the agent’s own routine. A line in your project rules file such as “run npx tsc --noEmit before saying a task is done” catches the break while the agent still has the context to fix it, instead of at deploy time.

If you did already commit ignoreBuildErrors: true, remove it now and run the check once. You will see every error that has been hiding since.

Comments