TypeScript Version: 2.1.4 on Windows 10
Expected behavior:
When running tsc -w with outDir set, it should remove existing files.
Actual behavior:
Old files are left in the output directory and it seems that sometimes they block the creation of the new files.
I do have other build tools watching the output directory and I wonder if this is a problem, because if I try to delete the folder manually while the build tools are running, I get a warning that the directory is locked.
The compiler does not delete files. deleting files entails user data loss, and it is not usually a thing that compilers do.
My recommendation is to add a clean task that deletes your outDir all together.
Ok, thanks
The compiler does not delete files. deleting files entails user data loss, and it is not usually a thing that compilers do.
this comment doesn't really line up with a compiler that can be (and is recommend to be) run in watch mode. In watch mode, the compiler is happy to overwrite files that it's generated, which entails the same amount of data loss. Deleting those files when the source files that generated them go away seems like the consistent thing to do, and needing to clean out all compiled files and start fresh seems like it defeats the purpose of incremental compilation with --watch.
Would you be open to a PR supporting this behavior behind a flag?
overwriting is different from deleting. deleting will have to be a complete directory, since the compiler does not what it wrote to it last time it ran. and deleting a whole folder is a very drastic action, and I would not be comfortable with a tool that does that un-announced.
Most helpful comment
this comment doesn't really line up with a compiler that can be (and is recommend to be) run in watch mode. In watch mode, the compiler is happy to overwrite files that it's generated, which entails the same amount of data loss. Deleting those files when the source files that generated them go away seems like the consistent thing to do, and needing to clean out all compiled files and start fresh seems like it defeats the purpose of incremental compilation with --watch.
Would you be open to a PR supporting this behavior behind a flag?