Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler Option --outDir should remove existing files #13722

Closed
ricklove opened this issue Jan 27, 2017 · 4 comments
Closed

Compiler Option --outDir should remove existing files #13722

ricklove opened this issue Jan 27, 2017 · 4 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@ricklove
Copy link

ricklove commented Jan 27, 2017

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.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 27, 2017

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.

@mhegazy mhegazy added the Working as Intended The behavior described is the intended behavior; this is not a bug label Jan 27, 2017
@ricklove
Copy link
Author

Ok, thanks

@ehberger
Copy link

ehberger commented Feb 3, 2017

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?

@mhegazy
Copy link
Contributor

mhegazy commented Feb 3, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants