gilamran/tsc-watch

tsc-watch re-compiling even when no file was modified

tabarra opened this issue · 4 comments

Unlike nodemon, esbuild, chokidar, etc. it seems like the file monitoring API being used is being triggered erroneously.
Env: Windows 10 updated, Node v19.6.0.
Command being used: "tsc-watch -p tsconfig.json --onSuccess \"node ./dist/index.js\""
There are no steps to reproduce it, but I notice this happens quite often when I just alt+tab back into vscode after a few minutes, and usually restarts the app twice really fast.

I noticed in the chokidar readme mentions some issues with the native file watch system.
Maybe check their lib and see if its interesting to use?

In most of the cases where i write code that watches files for change, i throttle or debounce it, specially important if a large project is being uploaded to some server, where it can take over a second to change all the files.
If you are interested in implementing something like that, i recommend you check lodash's debounce/throttle functions, and there is an amazing blog post about it here: https://llu.is/throttle-and-debounce-visualized/

tsc-watch is not doing the watch, it's using your installed version of typescript and just adds the --watch flag.
According to what you say, typescript itself will recompile twice... and if this is the case then, it's an issue in the typescript watch mechanism... Do you have any other ideas on how to approach this?
Did you check if typescript has this issue as well?

Did you check if typescript has this issue as well?

I did not.
So I guess safe to close this issue since it's a upstream problem?

@tabarra Did you find a solution for this issue? Currently investigating the same issue on a typescript monorepo setup with VSCode

@derN3rd I have not, I just accept that sometimes it will just restart multiple times in sequence when I switch to VSCode or even randomly.