tsc --watch should show file that triggered recompile
I am trying to find out why the watch task keeps recompiling whenever I bring the window of my git client in focus (my first guess was that .git/index.lock triggered it, it is the only file that fswatch points out as being changed. But it is located higher in the folder hierarchy than the folder that tsc is watching, so I am still puzzled..).
To debug something like this it would be very useful if the watch task would print the file name (perhaps only the first if multiple files changed) of the file that triggered the recompile.
TypeScript Version:
Version 1.8.0-dev.20151204
consider using --listFiles to identify the files the compiler is pulling in.
Also where is your tsconfig.json? how can we repro this locally?
tsconfig.json is located in the root of the folder that tsc is watching:
the hierarchy looks like this:
repo root
|_ .git (contains index.lock)
|_ source
|_ client
|_ server
|_ tsconfig.json
|_ build
tsc is watching the server folder.
I realize this is not enough to go on, as soon as I find the time to create an example folder structure and test if the issue is reproducible on another system I'll create a new issue.
In the mean time a feature that prints the file that triggered the recompile seems a useful addition.
We have changed the implementation of tsc --watch since this issue was filed. we believe it is fixed now. can you please give typescript@next a try and reopen if you are still experiencing the issue.
Looks like this is still not supported by "tsc --watch" or "--listFiles".
Steps to reproduce:
- Init a new TSC project
- Create files "first.ts", "second.ts", and "third.ts"
- In "first.ts", write
import * as second from "./second" - In "second.ts", write
import * as third from "./third" - Run
tsc -w --listFiles - Alter "first.ts" by adding a new blank line.
TSC will list all filles: first.ts, second.ts, and third.ts. There does not seem to be a way to get it to only list first.ts, i.e. the file that was changed.
(Sorry, this example might not be comprehensive, it might need actual exports & code in each module.)
-w still doesn't list which file triggers the recompilation in 2.8.1. As @laurence-myers mentioned, --listFiles list all files instead of just the changed files.
@mhegazy could you re-open this issue?
Would appreciate this, running into issue where for some reason packages keep getting triggered.
For me, it even recompiles on staging an unrelated file with git. For example, if I modified yarn.lock, it won't recompiles. But if I stage yarn.lock, it will.
You can run tsc --watch --diagnostics or tsc --watch --extendedDiagnostics and it will let you know which directoryWatcher/file watcher is being invoked. Note that not all triggers lead to recompilation.
@sheetalkamat thanks for the info. In 2.9.2, --diagnostics doesn't show which file are updated thus triggered the watch. --extendedDiagnostics does, it is very verbose though.