`tsc --build --watch` produces stray `.js`/`.js.map` files when adding a file to upstream project
#61,717 opened on 2025幎5æ17æ¥
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð 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:
project1andproject2 - The
.jsand.js.mapfiles should be outputted toproject1/dist/andproject2/dist/ project1defines some math functions thatproject2imports and uses- The git branches:
- the
mainbranch has the base code - the
multiply-functionbranch has one additional commit on top ofmain, which:- adds a
project1/src/multiply.tsfile which exports amultiplyfunction - and edits
project2/src/main.tsto import and use thatmultiplyfunction.
- adds a
- the
- The repo contains 2 TS projects:
- When you switch from
mainto themultiply-functionbranch whiletsc --build --watchis running from withinproject2/, then the following unwanted files are created:project1/src/multiply.jsproject1/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