Skip to content

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

Open
@ghost

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions