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
Code
I use TypeScript in a project with ~500 ts files. When I type in console tsc -w and wait for the whole project is compiled, I add a small changes to one of my files. It re-compiles whole project instead of one changed file (it takes 10-25 seconds). I used node-inspector to track what the reason of such behavior. I found out that when it performs re-compilation (tsc.ts:564), it creates a new program without passing an old program as a forth parameter to the function.
I created a small project for experiments with some files and start watcher with flag --listFiles:
The second time around with tsc -w the compiler actually does reuse syntax trees of all unmodified files (but by a different mechanism than passing a fourth argument to createProgram), thus saving the time it would take to read the files from disk and parse them. However, it type checks the entire program, and that definitely can be time consuming. Since changes in one file can cause type errors to occur in other files (e.g. imagine you delete a member from a type that is used in many files) there is really no good way to avoid this. It might be possible to construct and analyse a module dependency graph (if you're using ES6 modules) to exclude non-dependent modules, but it would be complicated by the ability of modules to augment other modules. Without a good deal of work I think we're being as incremental as we can be at the moment.
Can the process of compiling be a bit changed? A changed file can be compiled first and js file will be created almost instantly, but after that re-compile the rest of the project.
TypeScript Version:
I use typescript compiler 1.8.10 from npm.
Code
I use TypeScript in a project with ~500 ts files. When I type in console tsc -w and wait for the whole project is compiled, I add a small changes to one of my files. It re-compiles whole project instead of one changed file (it takes 10-25 seconds). I used node-inspector to track what the reason of such behavior. I found out that when it performs re-compilation (tsc.ts:564), it creates a new program without passing an old program as a forth parameter to the function.
I created a small project for experiments with some files and start watcher with flag --listFiles:
My tsconfig.json:
Expected behavior:
It should compile only one changed file (I added a space to the calc.ts files).
Actual behavior:
It re-compiles whole files:
I understand that such behavior can't be added for project that should be bundled into one file.
Thanks
The text was updated successfully, but these errors were encountered: