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

tsc should ignore hidden files by default (regression in 2.6) #29461

Closed
glasser opened this issue Jan 17, 2019 · 8 comments
Closed

tsc should ignore hidden files by default (regression in 2.6) #29461

glasser opened this issue Jan 17, 2019 · 8 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@glasser
Copy link

glasser commented Jan 17, 2019

TypeScript Version: 3.2.2

Search Terms: tsc watch hidden dot emacs

Code

glasser@glasser-mbp 0 /tmp $ mkdir tstest
glasser@glasser-mbp 0 /tmp $ cd tstest
glasser@glasser-mbp 0 /tmp/tstest $ echo '{"include": ["src/**/*.ts"]}' >tsconfig.json
glasser@glasser-mbp 0 /tmp/tstest $ mkdir src
glasser@glasser-mbp 0 /tmp/tstest $ touch src/foo.ts
glasser@glasser-mbp 0 /tmp/tstest $ npx -p typescript@3.2.2 tsc --build tsconfig.json --watch &
[1] 20017
glasser@glasser-mbp 0 /tmp/tstest $ npx: installed 1 in 1.452s
[12:52:03 PM] Starting compilation in watch mode...

[12:52:04 PM] Found 0 errors. Watching for file changes.


glasser@glasser-mbp 0 /tmp/tstest $ touch src/.foo.ts
glasser@glasser-mbp 0 /tmp/tstest $ �c[12:52:09 PM] File change detected. Starting incremental compilation...

[12:52:10 PM] Found 0 errors. Watching for file changes.


glasser@glasser-mbp 0 /tmp/tstest $ kill %1
[1]+  Terminated: 15          npx -p typescript@3.2.2 tsc --build tsconfig.json --watch
glasser@glasser-mbp 0 /tmp/tstest $ rm -rf src && mkdir src && touch src/foo.ts
glasser@glasser-mbp 0 /tmp/tstest $ npx -p typescript@2.6.1 tsc --project tsconfig.json --watch &
[1] 20062
glasser@glasser-mbp 0 /tmp/tstest $ npx: installed 1 in 1.646s
12:52:34 PM - Compilation complete. Watching for file changes.



glasser@glasser-mbp 0 /tmp/tstest $ touch src/.foo.ts
glasser@glasser-mbp 0 /tmp/tstest $ 12:52:41 PM - File change detected. Starting incremental compilation...



glasser@glasser-mbp 0 /tmp/tstest $ kill %1
[1]+  Terminated: 15          npx -p typescript@2.6.1 tsc --project tsconfig.json --watch
glasser@glasser-mbp 0 /tmp/tstest $ rm -rf src && mkdir src && touch src/foo.ts
glasser@glasser-mbp 0 /tmp/tstest $ npx -p typescript@2.5.3 tsc --project tsconfig.json --watch &
[1] 20107
glasser@glasser-mbp 0 /tmp/tstest $ npx: installed 1 in 1.35s
12:53:13 PM - Compilation complete. Watching for file changes.



glasser@glasser-mbp 0 /tmp/tstest $ touch src/bar.ts  # watching does work in general in this version
glasser@glasser-mbp 0 /tmp/tstest $ 12:53:26 PM - File change detected. Starting incremental compilation...


12:53:26 PM - Compilation complete. Watching for file changes.



glasser@glasser-mbp 0 /tmp/tstest $ touch src/.foo.ts

# no output happens --- 2.5.3 correctly ignores .foo.ts

Expected behavior:

Touching a file that starts with a dot should not trigger the watcher.

Actual behavior:

Touching a file that starts with a dot did not trigger the watcher in TS 2.0 through 2.5, but does trigger the watcher in 2.6 onward.

Related Issues:

This is the same issue filed by @evmar as #6861 in 2016. That issue was closed because it was fixed by #8484 in 2.0.2. However, it appears that the rewrite of the watcher in 2.6 (by @sheetalkamat I think) reintroduced the issue.

The impact of this issue is that emacs users with the default configuration will see tsc --watch refresh every time they start editing a file, because of emacs lock files. (As a workaround, Emacs users can stop using lock files with M-x customize-variable RET create-lockfiles.)

The original issue was considered to be important enough to fix in the first place, and I can't find anything showing that this change was intentional, so it seems like an unintended regression (though admittedly one that is over a year old).

@weswigham weswigham added the Bug A bug in TypeScript label Jan 17, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 14, 2019
@davazp
Copy link

davazp commented Sep 6, 2019

I think this is more important than it seems. It affects vim and potentially many other editors. Probably there are not many complaints because tsc -w will clear the screen and it is not very noticeable unless you use preserveWatchOutput, but they would probably be happy with the "performance improvement" 🙂.

@michaelsbradleyjr
Copy link

I experience the effects of this regression when editing my projects with Emacs on macOS but not when editing VS Code. With Emacs, when you have unsaved changes in /some/path/foo.ts, a .#foo.ts lockfile is created as a sibling of foo.ts.

@sheetalkamat
Copy link
Member

This should be fixed by #31954

@glasser
Copy link
Author

glasser commented Nov 20, 2019

Thanks @sheetalkamat and @suhasdeshpande !

@michaelsbradleyjr
Copy link

@glasser @sheetalkamat @suhasdeshpande I just found 13b7af6 in the commit history for the latest release (3.7.2) but I experienced this problem today in a project that has "typescript": "3.7.2" as a devDep.

@michaelsbradleyjr
Copy link

export const ignoredPaths = ["/node_modules/.", "/.git", "/.#"];

Is "/.#" possibly too restrictive, only ignoring .# files if they're in the root of the project? In my case, they could be found at any depth w/in src/ relative to the root of the project.

@sheetalkamat
Copy link
Member

They are handled at any depth since this is the check on absolute path to see of that pattern exists meaning file name starting with .#
I would recommend checking if that project is really using typescript 3.7.2 or not. If yes, then open a new issue with tsserver logs please.

@michaelsbradleyjr
Copy link

michaelsbradleyjr commented Nov 20, 2019

@sheetalkamat It is 100% definitely using typescript 3.7.2:

$ npx tsc --version
Version 3.7.2

I'm not sure about tsserver logs (please advise 🙏 ) but with:

$ npx tsc -b ./.tsconfig.collective.json --watch --preserveWatchOutput --verbose --extendedDiagnostic

(Note: the use of --preserveWatchOutput)

I got this when I started typing in Emacs within:

/some/path/some-package/src/index.ts
DirectoryWatcher:: Triggered with /some/path/some-package/src/.#index.ts :: WatchInfo: /some/path/some-package/src 1 Wild card directory /some/path/some-package/tsconfig.json
Elapsed:: 0ms DirectoryWatcher:: Triggered with /some/path/some-package/src/.#index.ts :: WatchInfo: /some/path/some-package/src 1 Wild card directory /some/path/some-package/tsconfig.json
[5:15:33 PM] File change detected. Starting incremental compilation...

I am confident at this point that #29461 should be re-opened rather than a new issue being created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

6 participants