TypeScript Version: On master (commit d6c05a135840dc3045ec8f3bbec1da5ffabb6593)
Search Terms:isProgramUptoDate, synchronize programupdate program.
Code
I was playing around with the TypeScript API and I noticed that if you update the root files of a watcher program with the same number of root files, the source files are not updated.
import*astsfrom'typescript';constwatchHost=ts.createWatchCompilerHost(['path/to/foo']);constprogram=ts.createWatchProgram(watchHost);console.log(constprogram.getProgram().getSourceFiles());// <- This has the expected sourcesprogram.updateRootFileNames(['/path/to/bar']);console.log(constprogram.getProgram().getSourceFiles());// <- This has the same source, but it shouldn't
Expected behavior:
The source files should be the expected ones (so include /path/to/bar).
Actual behavior:
The source files didn't change.
Playground Link: Can't reproduce in the playground as it's an API bug.
Related Issues: Didn't find any related issues.
This is the culprit:
| if(program.getRootFileNames().length!==rootFileNames.length){ |
It should check for array equality, not just array length. I'll make a PR real soon.
TypeScript Version: On
master(commitd6c05a135840dc3045ec8f3bbec1da5ffabb6593)Search Terms:
isProgramUptoDate,synchronize programupdate program.Code
I was playing around with the TypeScript API and I noticed that if you update the root files of a watcher program with the same number of root files, the source files are not updated.
Expected behavior:
The source files should be the expected ones (so include
/path/to/bar).Actual behavior:
The source files didn't change.
Playground Link: Can't reproduce in the playground as it's an API bug.
Related Issues: Didn't find any related issues.
This is the culprit:
TypeScript/src/compiler/program.ts
Line 575 in 3b396e6
It should check for array equality, not just array length. I'll make a PR real soon.