-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error "Cannot write file ... because it would overwrite input file." #27436
Comments
We need a way to reproduce the issue. |
Setting outDir in tsconfig removed the error in VS Code for me. In my case, I set it to /dev/shm. |
Having to explicitly set one option like I thing that the options should be decoupled - we shouldn't have to mandatory set one option to have another in a working state. Not to mention that you can still set the outDir` to the very same folder and cause the very same bug to reappear (which is creating a third rule - do not set outDir as the project dir...) |
I'm not 100% certain this is related, however I'm attempting to compile and deploy a NestJS app, and was getting this error on |
Make sure you have assigned an |
Try to run TypeScript compiler with npx tsc --listFiles in case when list have many entries it can be narrowed with npx tsc --listFiles | grep dist |
"exclude": ["node_modules", "**/*.test.ts", "dist"]
|
Fails with "error TS5055: Cannot write file '/Users/astoilkov/Repos/use-local-storage-state/dist/index.d.ts' because it would overwrite input file.". - https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file - microsoft/TypeScript#16394 - microsoft/TypeScript#27436 - microsoft/TypeScript#14538
Might be able to help you reproduce this issue... It seems like some part of the compilation process isn't recognizing that it is inside an excluded directory. I don't don't see the problem if I do this: "exclude": ["**/*.d.ts", "dist", "node_modules"] I do see the problem if I do this: "exclude": ["dist/**/*.d.ts", "dist", "node_modules"] or this: "exclude": ["**/dist/**/*.d.ts", "dist", "node_modules"] The error occurs despite the fact that the files it is complaining about are clearly inside error TS5055: Cannot write file '/Users/leila/dev/wip/jest-fp-ts/dist/index.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/leila/dev/wip/jest-fp-ts/dist/matchers/index.d.ts' because it would overwrite input file. In my case I have imports set up where The first two files are the ones with the compilation errors. The third file is fine. Other |
Ah... another important piece of the puzzle. I discovered I had a manually created Once I fixed that, the problem went away. So maybe not the same problem others are seeing - but one way to reproduce it... |
For me the problem was solved adding dist to exclude and |
This worked for me |
This might help anyone who ran into this issue: If adding the output directory to the exclude option didn't help, then check your source directory - you might accidentally import something from output directory in your sources. It also results in the aforementioned error |
We haven't seen any instance of this that isn't a misconfiguration #40011 should help in the future for diagnosing such problems |
This is because TypeScript defaults to parsing TS files to generate JS files that are placed in the same directory, which may have the potential to overwrite JS files. 这是因为TypeScript默认在解析TS文件生成JS文件是放在相同目录中的,这就有可能存在覆盖JS文件的可能。 |
Started getting this after upgrading from 3.0.3 to 3.1.1. Looks like the same problem as #14538
Using create-react-app Webpack 2 project with ts-loader 3.5.0. Still builds fine, but VS Code pops the tsconfig error. In our case, unlike most people in #14538, the file mentioned is one of our JS sources.
This is a TS/JS mixed project. Made no other changes other than upgrading TS to 3.1.1. No problems prior. Latest VS Code. Still builds fine otherwise.
The text was updated successfully, but these errors were encountered: