You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Typescript watch compiles each edited file twiceΒ #51611
let a: string = "123456790123";
alert(a.slice(0, 2));
π Actual behavior
In terminal, invoking npx and then tsc main.ts --watch, changing the source code of main.ts triggers Typescript watch to compile the file again - not once, but twice. The same took place in larger projects - double compilation of changed files, with one or two seconds in between.
π Expected behavior
Once a source code file has been changed, it should compile only once by tsc watch, not twice.
please post log with tsc --watch main.ts --extendedDiagnostics even though it looks like it has compiled twice the actual transformation should happen only once. It looks like on windows (which is where i tested) the file change event was generated twice which is why this behaviour.
Activity
eladstr commentedon Nov 21, 2022
GIST link:
https://gist.github.com/eladstr/53a764cd35b2045635c0397eb59a804b
sheetalkamat commentedon Nov 21, 2022
please post log with
tsc --watch main.ts --extendedDiagnosticseven though it looks like it has compiled twice the actual transformation should happen only once. It looks like on windows (which is where i tested) the file change event was generated twice which is why this behaviour.eladstr commentedon Nov 22, 2022
terminal output with --extendedDiagnostics:
sh-3.2$ tsc main.ts --watch --extendedDiagnostics
[10:18:14 AM] Starting compilation in watch mode...
Current directory: /Users/elads/Projects/testtsc CaseSensitiveFileNames: false
Synchronizing program
CreatingProgramWith::
roots: ["main.ts"]
options: {"watch":true,"extendedDiagnostics":true}
FileWatcher:: Added:: WatchInfo: main.ts 250 undefined Source file
FileWatcher:: Added:: WatchInfo: /Users/elads/Projects/testtsc/node_modules/typescript/lib/lib.d.ts 250 undefined Source file
FileWatcher:: Added:: WatchInfo: /Users/elads/Projects/testtsc/node_modules/typescript/lib/lib.es5.d.ts 250 undefined Source file
FileWatcher:: Added:: WatchInfo: /Users/elads/Projects/testtsc/node_modules/typescript/lib/lib.dom.d.ts 250 undefined Source file
FileWatcher:: Added:: WatchInfo: /Users/elads/Projects/testtsc/node_modules/typescript/lib/lib.webworker.importscripts.d.ts 250 undefined Source file
FileWatcher:: Added:: WatchInfo: /Users/elads/Projects/testtsc/node_modules/typescript/lib/lib.scripthost.d.ts 250 undefined Source file
DirectoryWatcher:: Added:: WatchInfo: /Users/elads/Projects/testtsc/node_modules/Types (@types) 1 undefined Type roots
Elapsed:: 0.2658340334892273ms DirectoryWatcher:: Added:: WatchInfo: /Users/elads/Projects/testtsc/node_modules/Types (@types) 1 undefined Type roots
[10:18:14 AM] Found 0 errors. Watching for file changes.
Files: 6
Lines of Library: 23413
Lines of Definitions: 0
Lines of TypeScript: 2
Lines of JavaScript: 0
Lines of JSON: 0
Lines of Other: 0
Identifiers: 39746
Symbols: 27134
Types: 9517
Instantiations: 2630
Memory used: 72906K
Assignability cache size: 3405
Identity cache size: 0
Subtype cache size: 0
Strict subtype cache size: 0
I/O Read time: 0.00s
Parse time: 0.12s
Program time: 0.13s
Bind time: 0.05s
Check time: 0.28s
printTime time: 0.01s
Emit time: 0.01s
transformTime time: 0.00s
commentTime time: 0.00s
I/O Write time: 0.00s
Total time: 0.47s
FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file
Scheduling update
Elapsed:: 0.469124972820282ms FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file
Synchronizing program
[10:18:24 AM] File change detected. Starting incremental compilation...
CreatingProgramWith::
roots: ["main.ts"]
options: {"watch":true,"extendedDiagnostics":true}
[10:18:24 AM] Found 0 errors. Watching for file changes.
Files: 6
Lines of Library: 23413
Lines of Definitions: 0
Lines of TypeScript: 2
Lines of JavaScript: 0
Lines of JSON: 0
Lines of Other: 0
Identifiers: 39746
Symbols: 27134
Types: 9517
Instantiations: 2630
Memory used: 91604K
Assignability cache size: 3405
Identity cache size: 0
Subtype cache size: 0
Strict subtype cache size: 0
I/O Read time: 0.00s
Parse time: 0.00s
Program time: 0.00s
Bind time: 0.00s
Check time: 0.26s
transformTime time: 0.01s
commentTime time: 0.00s
printTime time: 0.01s
Emit time: 0.01s
I/O Write time: 0.00s
Total time: 0.27s
FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file
Scheduling update
Elapsed:: 0.15825003385543823ms FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file
Synchronizing program
[10:18:25 AM] File change detected. Starting incremental compilation...
CreatingProgramWith::
roots: ["main.ts"]
options: {"watch":true,"extendedDiagnostics":true}
[10:18:25 AM] Found 0 errors. Watching for file changes.
Files: 6
Lines of Library: 23413
Lines of Definitions: 0
Lines of TypeScript: 2
Lines of JavaScript: 0
Lines of JSON: 0
Lines of Other: 0
Identifiers: 39746
Symbols: 23958
Types: 82
Instantiations: 0
Memory used: 78447K
Assignability cache size: 0
Identity cache size: 0
Subtype cache size: 0
Strict subtype cache size: 0
I/O Read time: 0.00s
Parse time: 0.00s
Program time: 0.00s
Bind time: 0.00s
Total time: 0.00s
thanks
sshrshnv commentedon Sep 8, 2024
The same error in Typescript version 5.5.4 (macOS)