-
Notifications
You must be signed in to change notification settings - Fork 13.3k
TS5055: Typescript includes files in "dist" folder for compilation when rootDir is not ./ but ./src even after explicitly adding "dist" to excludeΒ #58090
Description
π Search Terms
TS5055, rootDir, outDir, exclude
π Version & Regression Information
TypeScript 5.4.4
β― Playground Link
https://github.com/calebpitan/zne-repro
No response
π» Code
// Your code here
yarn install
cd ./libs/common
yarn tsc --build tsconfig.jsonThis fails with the TS5055 error and since it is the base of every other dependent workspace/lib package build for the others fail too, except I rimraf dist which works fine if I just want to do a one time build, but doesn't if I have to build-watch.
NOTE: Initial build always works fine, subsequent builds are the ones that fail.
π Actual behavior
Includes output files (mostly declaration output files) as part of input even after explicitly excluding them. This doesn't happen when I change rootDir from ./src to ./ (but unfortunately this creates an unwanted effect of emitting output to dist/src instead of just dist so I'd like to retain rootDir as ./src rather than ./)
π Expected behavior
Should not include output files in input files especially after explicitly excluding them
Additional information about the issue
tsconfig.json
tsconfig.base.json
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"target": "ES2022",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"isolatedModules": true,
"incremental": true,
"skipLibCheck": true,
"strict": true,
"strictNullChecks": true,
"strictPropertyInitialization": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
"resolveJsonModule": true,
"allowJs": false,
"jsx": "react",
"typeRoots": ["./@types", "node_modules/@types"],
"paths": {
"@/module/*": ["./apps/customer/src/module/v1/*"]
}
},
"watchOptions": {
"excludeDirectories": ["*/**/node_modules", "*/**/dist", "libs/**/dist"]
}
}First compilation runs smoothly, subsequent compilations error with:
error TS5055: Cannot write file '/Users/calebpitan/source/work/company/project/libs/customer/dist/constant.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/calebpitan/source/work/company/project/libs/customer/dist/index.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/calebpitan/source/work/company/project/libs/customer/dist/prisma.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/calebpitan/source/work/company/project/libs/customer/dist/prisma.enum.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/calebpitan/source/work/company/project/libs/customer/dist/prisma.module.d.ts' because it would overwrite input file.
{ "extends": "../../tsconfig.base.json", "compilerOptions": { "composite": true, "outDir": "./dist", "rootDir": "./src", "baseUrl": "." }, "include": ["src/**/*"], "exclude": ["node_modules", "dist"] }