Skip to content

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

Closed
evmar opened this issue Feb 3, 2016 · 8 comments
Closed

tsc should ignore hidden files by default #6861

evmar opened this issue Feb 3, 2016 · 8 comments
Labels
Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript

Comments

@evmar
Copy link
Contributor

evmar commented Feb 3, 2016

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 your tsconfig.json excludes section, so you instead must enumerate each source file in a files 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.

@mhegazy mhegazy added the Suggestion An idea for TypeScript label Feb 3, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Feb 3, 2016

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.

@mhegazy mhegazy added the Help Wanted You can do this label Feb 3, 2016
@RyanCavanaugh RyanCavanaugh added this to the Community milestone Feb 3, 2016
@RyanCavanaugh RyanCavanaugh added the Good First Issue Well scoped, documented and has the green light label Feb 3, 2016
@mhegazy mhegazy modified the milestones: TypeScript 2.0, Community Feb 3, 2016
@DanielRosenwasser
Copy link
Member

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.

@RyanCavanaugh
Copy link
Member

Do any other OSes use a leading dot for something else?

@DanielRosenwasser
Copy link
Member

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, node_modules, minified JS files, etc.

@billti
Copy link
Member

billti commented Feb 12, 2016

This is interesting, and applies to directories as well as files. Directories such as .git and .vscode are unlikely to contain code you want included also (or even want to take the time to scan).

@evmar
Copy link
Contributor Author

evmar commented Feb 12, 2016

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.

@bowdenk7
Copy link

have a set of implicit exclude globs

You wouldn't have to modify tsconfig.

@evmar
Copy link
Contributor Author

evmar commented Feb 12, 2016

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) &&

@zhengbli zhengbli added the Fixed A PR has been merged for this issue label May 6, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

7 participants