Microsoft/TypeScript

`tsc --build --watch` produces stray `.js`/`.js.map` files when adding a file to upstream project

Open

#61.717 aperta il 17 mag 2025

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)TypeScript (6726 fork)batch import
BugDomain: tsc -bHelp Wanted

Metriche repository

Star
 (48.455 star)
Metriche merge PR
 (Merge medio 6g 17h) (9 PR mergiate in 30 g)

Descrizione

🔎 Search Terms

tsc build watch extra unwanted stray .js .js.map files projects

🕗 Version & Regression Information

  • This changed between versions 5.5 and 5.6

⏯ Playground Link

No response

💻 Code

Repo with the repro: https://github.com/echentw/tsc-watch-bug-repro

  • Instructions for repro-ing are under "Bug 1 repro instructions".

Description of the repro:

  • The setup:
    • The repo contains 2 TS projects: project1 and project2
    • The .js and .js.map files should be outputted to project1/dist/ and project2/dist/
    • project1 defines some math functions that project2 imports and uses
    • The git branches:
      • the main branch has the base code
      • the multiply-function branch has one additional commit on top of main, which:
        • adds a project1/src/multiply.ts file which exports a multiply function
        • and edits project2/src/main.ts to import and use that multiply function.
  • When you switch from main to the multiply-function branch while tsc --build --watch is running from within project2/, then the following unwanted files are created:
    • project1/src/multiply.js
    • project1/src/multiply.js.map

I checked that this doesn't happen with TS version 5.5, but it does happen with TS version 5.6 and onwards.

🙁 Actual behavior

project1/src/multiply.js and project1/src/multiply.js.map are created

🙂 Expected behavior

project1/src/multiply.js and project1/src/multiply.js.map should not be created

Additional information about the issue

Ideally, switching branches or modifying code while tsc --build --watch is running wouldn't produce stray .js/.js.map files. They are unpleasant to deal with and can be accidentally committed.

No response

Guida contributor