@@ -6,6 +6,7 @@ namespace ts {
66 finishRecordingFilesWithChangedResolutions ( ) : Path [ ] ;
77
88 resolveModuleNames ( moduleNames : string [ ] , containingFile : string , reusedNames : string [ ] | undefined ) : ResolvedModuleFull [ ] ;
9+ getResolvedModuleWithFailedLookupLocationsFromCache ( moduleName : string , containingFile : string ) : ResolvedModuleWithFailedLookupLocations ;
910 resolveTypeReferenceDirectives ( typeDirectiveNames : string [ ] , containingFile : string ) : ResolvedTypeReferenceDirective [ ] ;
1011
1112 invalidateResolutionOfFile ( filePath : Path ) : void ;
@@ -73,7 +74,7 @@ namespace ts {
7374 export const maxNumberOfFilesToIterateForInvalidation = 256 ;
7475
7576 type GetResolutionWithResolvedFileName < T extends ResolutionWithFailedLookupLocations = ResolutionWithFailedLookupLocations , R extends ResolutionWithResolvedFileName = ResolutionWithResolvedFileName > =
76- ( resolution : T ) => R ;
77+ ( resolution : T ) => R | undefined ;
7778
7879 export function createResolutionCache ( resolutionHost : ResolutionCacheHost , rootDirForResolution : string , logChangesWhenResolvingModule : boolean ) : ResolutionCache {
7980 let filesWithChangedSetOfUnresolvedImports : Path [ ] | undefined ;
@@ -124,6 +125,7 @@ namespace ts {
124125 startCachingPerDirectoryResolution : clearPerDirectoryResolutions ,
125126 finishCachingPerDirectoryResolution,
126127 resolveModuleNames,
128+ getResolvedModuleWithFailedLookupLocationsFromCache,
127129 resolveTypeReferenceDirectives,
128130 removeResolutionsOfFile,
129131 invalidateResolutionOfFile,
@@ -320,7 +322,7 @@ namespace ts {
320322 }
321323
322324 function resolveTypeReferenceDirectives ( typeDirectiveNames : string [ ] , containingFile : string ) : ResolvedTypeReferenceDirective [ ] {
323- return resolveNamesWithLocalCache (
325+ return resolveNamesWithLocalCache < ResolvedTypeReferenceDirectiveWithFailedLookupLocations , ResolvedTypeReferenceDirective > (
324326 typeDirectiveNames , containingFile ,
325327 resolvedTypeReferenceDirectives , perDirectoryResolvedTypeReferenceDirectives ,
326328 resolveTypeReferenceDirective , getResolvedTypeReferenceDirective ,
@@ -329,14 +331,19 @@ namespace ts {
329331 }
330332
331333 function resolveModuleNames ( moduleNames : string [ ] , containingFile : string , reusedNames : string [ ] | undefined ) : ResolvedModuleFull [ ] {
332- return resolveNamesWithLocalCache (
334+ return resolveNamesWithLocalCache < ResolvedModuleWithFailedLookupLocations , ResolvedModuleFull > (
333335 moduleNames , containingFile ,
334336 resolvedModuleNames , perDirectoryResolvedModuleNames ,
335337 resolveModuleName , getResolvedModule ,
336338 reusedNames , logChangesWhenResolvingModule
337339 ) ;
338340 }
339341
342+ function getResolvedModuleWithFailedLookupLocationsFromCache ( moduleName : string , containingFile : string ) : ResolvedModuleWithFailedLookupLocations | undefined {
343+ const cache = resolvedModuleNames . get ( resolutionHost . toPath ( containingFile ) ) ;
344+ return cache && cache . get ( moduleName ) ;
345+ }
346+
340347 function isNodeModulesDirectory ( dirPath : Path ) {
341348 return endsWith ( dirPath , "/node_modules" ) ;
342349 }
0 commit comments