Open
Description
TypeScript Version: 3.1.0-dev.20180807
Search Terms:
Repro
declare let oldProgram: ts.Program;
const originalHost = ts.createCompilerHost(true);
const host = {
... originalHost,
getSourceFile(fileName, ...args) {
console.log(fileName);
return originalHost.getSoruceFile(fileName, ...args);
}
const newProgram = ts.createProgram(oldProgram.getRootFileNames(), oldProgram.getCompilerOptions(), host, oldProgram);
Expected behavior:
Each fileName is logged once.
Actual behavior:
If structureIsReused !== Completely
fileNames are logged twice: one time from tryReuseStructureFromOldProgram
and another time from findSourceFile
. That means these SourceFiles are requested multiple times. This is especially a problem with the default CompilerHost which has no caching. It therefore reads and parses each file multiple times, but only the last one is actually used.