Skip to content

Suggest changing error message / adding more details for TS5055 #46992

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

Open
5 tasks done
ghost opened this issue Dec 2, 2021 · 3 comments
Open
5 tasks done

Suggest changing error message / adding more details for TS5055 #46992

ghost opened this issue Dec 2, 2021 · 3 comments
Labels
Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Milestone

Comments

@ghost
Copy link

ghost commented Dec 2, 2021

Suggestion

There are a number of issues (#29549, #16749, #35082, #35541, probably many others) that all think this error:

error TS5055: Cannot write file '/path/to/file.d.ts' because it would overwrite input file.

is a bug. I was about to open another one.

I believe the fundamental issue here is that most people, myself included, believe this is saying that /path/to/file.d.ts is explicitly being included in the tsconfig, e.g. through some weird combination of includes, rootDir, etc, and we all spend time banging our heads trying to figure out how the config is messed up.

What it's actually saying is that /path/to/file.d.ts is somehow being included either via tsconfig.json or an import/require statement in your project. For several of these issues, the reason is because the import was referencing the root project folder, and consequently the build folder. In my specific case, VSCode's auto-import referenced the project name I was currently in for some reason, instead of the relative path to a file.

I'm not quite sure how to re-phrase the error, but adding details such as the ones included in --explainFiles would be a huge help.

error TS5055: Cannot write file '/project/build/file.d.ts' because it would overwrite input file.
  Imported via '../../file' from file 'src/index.ts'

In my specific case, --explainFiles didn't even contain the offending file (no idea why), making the problem that much harder to figure out.

🔍 Search Terms

TS5055

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

📃 Motivating Example

💻 Use Cases

I believe a clearer error message & details would be very helpful to a lot of people

@fatcerberus
Copy link

In my specific case, VSCode's auto-import referenced the project name I was currently in for some reason, instead of the relative path to a file.

This part sounds related to #45953.

@ghost
Copy link
Author

ghost commented Dec 2, 2021

Possibly, but I realized it could also have been a refactor and a file got moved from one repo to another. I honestly don't know why there was one file with import from 'current-project' vs a relative import, but it utterly broke the build 😭

@RyanCavanaugh RyanCavanaugh added Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript labels Dec 3, 2021
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Dec 3, 2021
@RyanCavanaugh
Copy link
Member

I think your observation is keen. At minimum, a rephrasing would be nice, and if it's possible to reconstruct the "why is this here" information from data we already collect, that'd be cool too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants