Skip to content

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

Open
@echentw

Description

@echentw

πŸ”Ž 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions