Skip to content

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

Closed

Description

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:

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

Activity

  1. sheetalkamat commented on Nov 6, 2019

    @sheetalkamat
    Member

    This is introduced in #32372

  2. StoneCypher commented on Nov 24, 2019

    @StoneCypher

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

  3. weswigham commented on Nov 24, 2019

    @weswigham
    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.

  4. thovden commented on Nov 25, 2019

    @thovden
    Author

    Wesley Wigham (@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.

  5. weswigham commented on Nov 25, 2019

    @weswigham
    Member

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

  6. StoneCypher commented on Dec 4, 2019

    @StoneCypher

    Wesley Wigham (@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.
  7. StoneCypher commented on Dec 4, 2019

    @StoneCypher

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

  8. StoneCypher commented on Dec 4, 2019

    @StoneCypher

    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

  9. thovden commented on Jan 31, 2020

    @thovden
    Author

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

  10. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions