@@ -2377,7 +2377,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2377
2377
2378
2378
// check if program source files has changed in the way that can affect structure of the program
2379
2379
const newSourceFiles : SourceFile [ ] = [ ] ;
2380
- const modifiedSourceFiles : { oldFile : SourceFile ; newFile : SourceFile ; } [ ] = [ ] ;
2380
+ const modifiedSourceFiles : SourceFile [ ] = [ ] ;
2381
2381
structureIsReused = StructureIsReused . Completely ;
2382
2382
2383
2383
// If the missing file paths are now present, it can change the progam structure,
@@ -2489,14 +2489,19 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2489
2489
}
2490
2490
2491
2491
// tentatively approve the file
2492
- modifiedSourceFiles . push ( { oldFile : oldSourceFile , newFile : newSourceFile } ) ;
2492
+ modifiedSourceFiles . push ( newSourceFile ) ;
2493
2493
}
2494
2494
else if ( hasInvalidatedResolutions ( oldSourceFile . path ) ) {
2495
2495
// 'module/types' references could have changed
2496
2496
structureIsReused = StructureIsReused . SafeModules ;
2497
2497
2498
2498
// add file to the modified list so that we will resolve it later
2499
- modifiedSourceFiles . push ( { oldFile : oldSourceFile , newFile : newSourceFile } ) ;
2499
+ modifiedSourceFiles . push ( newSourceFile ) ;
2500
+ }
2501
+ else {
2502
+ for ( const moduleName of oldSourceFile . ambientModuleNames ) {
2503
+ ambientModuleNameToUnmodifiedFileName . set ( moduleName , oldSourceFile . fileName ) ;
2504
+ }
2500
2505
}
2501
2506
2502
2507
// if file has passed all checks it should be safe to reuse it
@@ -2507,16 +2512,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
2507
2512
return structureIsReused ;
2508
2513
}
2509
2514
2510
- const modifiedFiles = modifiedSourceFiles . map ( f => f . oldFile ) ;
2511
- for ( const oldFile of oldSourceFiles ) {
2512
- if ( ! contains ( modifiedFiles , oldFile ) ) {
2513
- for ( const moduleName of oldFile . ambientModuleNames ) {
2514
- ambientModuleNameToUnmodifiedFileName . set ( moduleName , oldFile . fileName ) ;
2515
- }
2516
- }
2517
- }
2518
2515
// try to verify results of module resolution
2519
- for ( const { newFile : newSourceFile } of modifiedSourceFiles ) {
2516
+ for ( const newSourceFile of modifiedSourceFiles ) {
2520
2517
const moduleNames = getModuleNames ( newSourceFile ) ;
2521
2518
const resolutions = resolveModuleNamesReusingOldState ( moduleNames , newSourceFile ) ;
2522
2519
const oldResolutions = oldProgram . resolvedModules ?. get ( newSourceFile . path ) ;
0 commit comments