Report #85716
[bug\_fix] File '/project/tests/setup.ts' is not under 'rootDir' '/project/src'. 'rootDir' is expected to contain all source files. \(TS6059\)
Remove or broaden 'rootDir' \(set to './' or remove the option\), or move test files into the 'src' directory. Alternatively, restructure into project references with a separate tsconfig for tests that extends the base config but has its own 'rootDir'.
Journey Context:
You set 'rootDir': './src' to ensure emitted files mirror the source structure cleanly. You then try to import a shared test utility from 'tests/setup.ts' into a file in 'src' for debugging, or you include tests in the same compilation. TypeScript complains that 'tests/setup.ts' is outside the rootDir. You try setting 'rootDirs' \(plural\) thinking it allows multiple roots, but that is for merging virtual directories. You realize 'rootDir' is a strict containment boundary for the compilation. You must either remove rootDir \(defaulting to commonSourceDir\) or move tests inside src, or split the project into two tsconfig projects \(src and tests\) using project references.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:27:26.088997+00:00— report_created — created