7
7
CompilerOptions ,
8
8
createModeAwareCache ,
9
9
createModuleResolutionCache ,
10
- createMultiMap ,
11
10
createTypeReferenceDirectiveResolutionCache ,
12
11
createTypeReferenceResolutionLoader ,
13
12
Debug ,
@@ -418,7 +417,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
418
417
let filesWithChangedSetOfUnresolvedImports : Path [ ] | undefined ;
419
418
let filesWithInvalidatedResolutions : Set < Path > | undefined ;
420
419
let filesWithInvalidatedNonRelativeUnresolvedImports : ReadonlyMap < Path , readonly string [ ] > | undefined ;
421
- const nonRelativeExternalModuleResolutions = createMultiMap < string , ResolutionWithFailedLookupLocations > ( ) ;
420
+ const nonRelativeExternalModuleResolutions = new Set < ResolutionWithFailedLookupLocations > ( ) ;
422
421
423
422
const resolutionsWithFailedLookups = new Set < ResolutionWithFailedLookupLocations > ( ) ;
424
423
const resolutionsWithOnlyAffectingLocations = new Set < ResolutionWithFailedLookupLocations > ( ) ;
@@ -583,8 +582,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
583
582
libraryResolutionCache . clearAllExceptPackageJsonInfoCache ( ) ;
584
583
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
585
584
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
586
- nonRelativeExternalModuleResolutions . forEach ( watchFailedLookupLocationOfNonRelativeModuleResolutions ) ;
587
- nonRelativeExternalModuleResolutions . clear ( ) ;
585
+ watchFailedLookupLocationOfNonRelativeModuleResolutions ( ) ;
588
586
}
589
587
590
588
function cleanupLibResolutionWatching ( newProgram : Program | undefined ) {
@@ -603,8 +601,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
603
601
function finishCachingPerDirectoryResolution ( newProgram : Program | undefined , oldProgram : Program | undefined ) {
604
602
filesWithInvalidatedNonRelativeUnresolvedImports = undefined ;
605
603
allModuleAndTypeResolutionsAreInvalidated = false ;
606
- nonRelativeExternalModuleResolutions . forEach ( watchFailedLookupLocationOfNonRelativeModuleResolutions ) ;
607
- nonRelativeExternalModuleResolutions . clear ( ) ;
604
+ watchFailedLookupLocationOfNonRelativeModuleResolutions ( ) ;
608
605
// Update file watches
609
606
if ( newProgram !== oldProgram ) {
610
607
cleanupLibResolutionWatching ( newProgram ) ;
@@ -944,7 +941,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
944
941
watchFailedLookupLocationOfResolution ( resolution ) ;
945
942
}
946
943
else {
947
- nonRelativeExternalModuleResolutions . add ( name , resolution ) ;
944
+ nonRelativeExternalModuleResolutions . add ( resolution ) ;
948
945
}
949
946
const resolved = getResolutionWithResolvedFileName ( resolution ) ;
950
947
if ( resolved && resolved . resolvedFileName ) {
@@ -1065,14 +1062,9 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1065
1062
}
1066
1063
}
1067
1064
1068
- function watchFailedLookupLocationOfNonRelativeModuleResolutions ( resolutions : ResolutionWithFailedLookupLocations [ ] , name : string ) {
1069
- const program = resolutionHost . getCurrentProgram ( ) ;
1070
- if ( ! program || ! program . getTypeChecker ( ) . tryFindAmbientModuleWithoutAugmentations ( name ) ) {
1071
- resolutions . forEach ( watchFailedLookupLocationOfResolution ) ;
1072
- }
1073
- else {
1074
- resolutions . forEach ( resolution => watchAffectingLocationsOfResolution ( resolution , /*addToResolutionsWithOnlyAffectingLocations*/ true ) ) ;
1075
- }
1065
+ function watchFailedLookupLocationOfNonRelativeModuleResolutions ( ) {
1066
+ nonRelativeExternalModuleResolutions . forEach ( watchFailedLookupLocationOfResolution ) ;
1067
+ nonRelativeExternalModuleResolutions . clear ( ) ;
1076
1068
}
1077
1069
1078
1070
function setDirectoryWatcher ( dir : string , dirPath : Path , nonRecursive ?: boolean ) {
0 commit comments