Description
TypeScript Version: 3.7.5
Search Terms:
tsc incremental doesn't clean old files
Code
N/A
Expected behavior:
When, for example, refactoring by renaming a file (and VS Code updates all import statements, etc), then the outputDir should not contain the old file.
Actual behavior:
The output directory contains old unused files.
Prior to trying incremental builds (today for the first time) I was simply doing rm -rf dist/
to "clean" it first. This doesn't work with incremental builds (#30602).
I tried running tsc --build --clean
and tsc --build ./tsconfig.json --clean
but those don't do anything, old files still remain in the output folder.
Note, I have a single tsconfig.json at the root of my project, and compile all my source code into a single output directory all at once with a single tsc
command. I'm not "composing projects".
Playground Link:
N/A
Related Issues:
- Incremental --build, then delete generated js file, then another incremental --build does not recreate js file #30602
- Compiler Option --outDir should remove existing files #13722 - @mhegazy mentions there that we should add our clean step, but like I mentioned that doesn't play well with incremental builds. I believe TS should handle this somehow.