Skip to content

tsc -watch should ignore files without extensions, pretends to hang during compilation instead #46949

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
mkhl opened this issue Nov 29, 2021 · 2 comments · Fixed by #47427
Closed
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@mkhl
Copy link

mkhl commented Nov 29, 2021

Bug Report

🔎 Search Terms

  • watch
  • extension
  • change
  • detected

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about ...watching files?
  • I was unable to test this on prior versions because I haven't used typescript in a while
  • This behavior is present in typescript nightly 4.6.0-dev.20211126

⏯ Playground Link

mkhl/issue-tsc-watch-should-ignore-files-without-extension (branch next for typescript nightly)

A playground won't work because it's not the handling of typescript code that's problematic but of other additional files

💻 Code

🙁 Actual behavior

  1. tsc -watch -p ./
  2. touch foo or mkdir
  3. tsc output:

    File change detected. Starting incremental compilation...

Note that touching a relevant file (like index.ts results in normal output resuming).
Note also that with this behavior, the user and tools that scan tsc output, like visual studio code, may assume that they have to wait for tsc to finish compilation.
(That's in fact what vscode does, which led me here.)

🙂 Expected behavior

Since a file without an extension or an empty directory don't require recompilation, tsc should ignore them and not output anything.
It already handles files with irrelevant extensions this way (like foo.txt).

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Nov 30, 2021
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.6.0 milestone Nov 30, 2021
@jakebailey
Copy link
Member

I don't think this has to do particularly with files without extensions; rather, the first message is printed when the FS event happens, then after it skips recreation of the Program because nothing applicable changed, and so the second message never gets printed because the program never changed.

Either:

  • The first message shouldn't be printed at all, i.e. check early if anything changed, but this might cause delay (I'm unsure how long that step takes).
  • In watch mode, just reprint the last results.

I'm not 100% sure which is the right solution; I'd think the former as it means clients watching the output would not do unnecessary things based on spurious events.

@mkhl
Copy link
Author

mkhl commented Dec 1, 2021

I don't think this has to do particularly with files without extensions
[...]
I'm not 100% sure which is the right solution

since files with irrelevant extensions (eg foo.txt) are already being handled correctly i'd assume the right solution would be to do the same thing for this case

@jakebailey jakebailey removed the Fix Available A PR has been opened for this issue label Dec 9, 2021
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
4 participants