The new validator doesn't work with rootDir tsconfig property
@bgub is already working on this.
Since Aug 27, 2025.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/ecl1ps/next-validator-rootdir/commit/3490369c43c6d8915cb8279ec9b9cc0a86d2cb5e
To Reproduce
- pnpm install
- pnpm build
Current vs. Expected behavior
The new validator breaks the build when you use rootDir and your sources are not at the top level of the repo.
> next build
▲ Next.js 15.5.1-canary.2
Linting and checking validity of types ...Failed to compile.
Type error: File 'C:/data/repos/next-validator-rootdir/.next/types/validator.ts' is not under 'rootDir' 'C:/data/repos/next-validator-rootdir/src'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Root file specified for compilation
Next.js build worker exited with code: 1 and signal: null
It is expected to work with the rootDir.
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 32401
Available CPU cores: 20
Binaries:
Node: 24.6.0
npm: 11.5.1
Yarn: N/A
pnpm: 10.0.0
Relevant Packages:
next: 15.5.1-canary.2 // Latest available version is detected (15.5.1-canary.2).
eslint-config-next: N/A
react: 19.1.1
react-dom: 19.1.1
typescript: 5.9.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Output
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
BTW, why don't you export types like ApiRouteConfig, PagesPageConfig, and AppPageConfig (which you AFAIK define only inside the new validator). We could use them to type our pages and API routes and get the validation even earlier, in the IDE. This was a breaking change for us as well, because the new validator is stricter, and specific types were not defined by Next. :(
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.