Skip to content
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

TS5056 when using JSON and TS files with the same basename in composite project #34943

Closed
thovden opened this issue Nov 6, 2019 · 9 comments
Closed
Assignees
Labels
Bug A bug in TypeScript

Comments

@thovden
Copy link

thovden commented Nov 6, 2019

TypeScript Version: 3.7.2

Search Terms: TS5056 composite JSON

Code

Minimal reproduction repo https://github.com/thovden/ts37-ts5056-composite

Compilation fails with a TS5056 when the basename of a Typescript and JSON file is the same in a composite project when using resolveJsonModule

# Project compiles fine without composite
tsc

# Using a composite project does not...
tsc -p tsconfig.composite.json
error TS5056: Cannot write file '.../ts37-ts5056-composite/dist/test.d.ts' because it would be overwritten by multiple input files.

Expected behavior:

Compiles fine in a composite project.

Actual behavior:

error TS5056: Cannot write file '.../ts37-ts5056-composite/dist/test.d.ts' because it would be overwritten by multiple input files.

Playground Link:

Related Issues:

@sheetalkamat has been working on related issues - e.g., #34676 , #33827

@sheetalkamat
Copy link
Member

This is introduced in #32372

@sheetalkamat sheetalkamat added this to the TypeScript 3.7.2 milestone Nov 6, 2019
@StoneCypher
Copy link

This hit me under rollup because the name of a source file collided with the name of the eventual bundle

@weswigham
Copy link
Member

This issue is only about the json case, as previously is worked since json files had no output - for other files whose outputs conflict, the error is expected. You should probably just use a different name for one of the inputs.

@thovden
Copy link
Author

thovden commented Nov 25, 2019

@weswigham I can change my code, but it's more difficult to change libraries I depend on. For example, https://loopback.io/ version 3 requires the model specification file named model.json and the controller named model.js. So I'm effectively not able to use Typescript 3.7 in this project due to this. A tsconfig.json flag to suppress emit from JSON files would be a sufficient solution for me.

@weswigham
Copy link
Member

Moreso talking to @StoneCypher - his issue seems a bit different, and the same error is used in situations not involving json files.

@StoneCypher
Copy link

@weswigham - ya, I mean, I kind of get that it's my fault, and sort of a dumbassed thing to have done

What was going on was I was trying to make a video that showed how to do rollup / typescript / react from scratch with no generators or whatever, and to underscore how easy it actually is

And so I copy pastaed the rollup config, and since I did somehow less than zero planning on the video, I just sort of munged the filenames and whatnot on the fly

And so I just called them both index, because here's my middle finger regarding thinking, at all, especially while making a video, but also sort of in general. And once I eventually just renamed the bundle output to bundle, everything switched back to common sense mode

And you're right, my problem is clearly different than theirs

My goals in commenting here are four-fold

  1. I would like to support people like me who get here when googling the dumb thing I did and as such that I assume other people will also do, as this is where the pagerank eigenmonster currently points
  2. I would like to raise to your attention that two entirely unrelated situations result in a shared and fairly inscrutable error message. The error messages in an ideal case might be bifurcated, or should that prove impractical, the error text might say something like "hey, dummy, ps, don't reuse filenames"
  3. I also get to hang a lantern on that the error message structure in TypeScript, while precise, doesn't seem to put much effort into telling your users what they might have done; only what the problem is. The former is really quite nice. c++ people should hear concepts here. Parser people should hear peg-style error messages.
  4. If there is an extant issue about my problem instead, I was hoping someone with better search skills than my own might cross-link it.

@StoneCypher
Copy link

also for the record i adore typescript and you folks have saved me enormous pain

@StoneCypher
Copy link

amusingly because i was trying to make a youtube tutorial, i actually have a video of myself hitting the bug, and getting pissed off while i try to figure out what's happening

it's kinda fun to watch

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Dec 18, 2019
@thovden
Copy link
Author

thovden commented Jan 31, 2020

This is no longer a problem in 3.7.5 9ba45fc . Thanks!

@thovden thovden closed this as completed Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants