Skip to content

isolatedDevBuild causes typescript issues when running next build with stale dev types #96620

Description

@SantoJambit

Link to the code that reproduces this issue

https://github.com/SantoJambit/next-dev-build-issue

To Reproduce

  1. npm ci
  2. npm run dev
  3. Open http://localhost:3000/api/hello in a browser
  4. git checkout issue
  5. npm run build
  6. notice an error

Current vs. Expected behavior

I'm getting the following error:

.next/dev/types/validator.ts(62,39): error TS2307: Cannot find module '../../../app/api/hello/route.js' or its corresponding type declarations.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sat, 04 Jul 2026 20:51:33 +0000
  Available memory (MB): 31395
  Available CPU cores: 16
Binaries:
  Node: 22.23.1
  npm: 10.9.8
  Yarn: 4.1.1
  pnpm: N/A
Relevant Packages:
  next: 16.3.0 // Latest available version is detected (16.3.0).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: standalone

Which area(s) are affected? (Select all that apply)

TypeScript

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

When I delete .next/dev/types, the error goes away.

I'm assuming this is due to the tsconfig entries:

  "include": [
    ...
    ".next/types/**/*.ts",
    ".next/dev/types/**/*.ts"
  ],

Removing them doesn't work though, since next.js just keeps bringing them back on build.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeScriptRelated to types with Next.js.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions