-
Notifications
You must be signed in to change notification settings - Fork 12.8k
tsc should ignore hidden files by default #6861
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
Comments
This sounds like a good suggestion. We would be open to accept a PR for this. i would not expect this to be a big change. |
This is a very OS-specific convention, and if users want to avoid adding files starting with dots, globs could solve this. This is the wrong solution to approaching the issue. |
Do any other OSes use a leading dot for something else? |
It doesn't appear so, but @mhegazy @bowdenk7 and I spoke offline. It would be acceptable to do this, but we should generalize this behavior. A better way to approach this is still globs, but have a set of implicit exclude globs so that we can apply the same changes for dot files, |
This is interesting, and applies to directories as well as files. Directories such as |
I appreciate that globs could be used to solve this, but I also think it's the wrong solution. You shouldn't require each user to manually configure their tsconfig to exclude dotfiles given that they are hidden files that are already excluded by default in other tools, much for the same reason tsc shouldn't find hidden files on Windows by default either. |
You wouldn't have to modify tsconfig. |
For precedent, I'll add that CoffeeScript's --watch flag ignores hidden files: hidden = (file) -> /^\.|~$/.test file Facebook's flow also ignores hidden files: let is_valid_path ~options =
let file_exts = Options.module_file_exts options in
let is_valid_path_helper path =
not (is_dot_file path) && |
On Unixy platforms, tsc should by default not attempt to compile files that begin with a dot (hereafter called "hidden files"). These files are intended to be hidden, and in practice any file that has a name like
.foo.ts
is always a temporary file written by an editor while saving.Currently, when you run
tsc --watch
in a directory and hit save in emacs, tsc picks up the hidden temporary file and attempts to compile it, resulting in duplicate definition errors (between the temporary file and the real source file). And it's surprisingly annoying to work around this problem -- you can't use a glob in yourtsconfig.json
excludes
section, so you instead must enumerate each source file in afiles
section.It is pretty standard on Unixes to ignore hidden files. For example the shell "*" ignores hidden files by default, as seen in the output of commands like
ls *
.I cannot think of any circumstance where someone would want to bring in a hidden file to their compilation, but if they did perhaps they could do so manually via the
files
section -- it's definitely the sort of thing you ought to need to opt in to.The text was updated successfully, but these errors were encountered: