@@ -199,6 +199,8 @@ export interface ResolutionCacheHost extends MinimalResolutionCacheHost {
199199 fileIsOpen ( filePath : Path ) : boolean ;
200200 onDiscoveredSymlink ?( ) : void ;
201201
202+ skipWatchingFailedLookups ?( path : Path ) : boolean | undefined ;
203+
202204 // For incremental testing
203205 beforeResolveSingleModuleNameWithoutWatching ?(
204206 moduleResolutionCache : ModuleResolutionCache ,
@@ -895,7 +897,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
895897 resolutionHost . onDiscoveredSymlink ( ) ;
896898 }
897899 resolutionsInFile . set ( name , mode , resolution ) ;
898- if ( resolution !== existingResolution ) {
900+ if ( resolution !== existingResolution && ! resolutionHost . skipWatchingFailedLookups ?. ( path ) ) {
899901 watchFailedLookupLocationsOfExternalModuleResolutions ( name , resolution , path , getResolutionWithResolvedFileName , deferWatchingNonRelativeResolution ) ;
900902 if ( existingResolution ) {
901903 stopWatchFailedLookupLocationOfResolution ( existingResolution , path , getResolutionWithResolvedFileName ) ;
@@ -921,10 +923,10 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
921923 Diagnostics . Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
922924 Diagnostics . Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved :
923925 resolved ?. resolvedFileName ?
924- resolved . packageId ?
925- Diagnostics . Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
926- Diagnostics . Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
927- Diagnostics . Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved ,
926+ resolved . packageId ?
927+ Diagnostics . Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
928+ Diagnostics . Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
929+ Diagnostics . Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved ,
928930 name ,
929931 containingFile ,
930932 resolved ?. resolvedFileName ,
@@ -947,7 +949,9 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
947949 // Stop watching and remove the unused name
948950 resolutionsInFile . forEach ( ( resolution , name , mode ) => {
949951 if ( ! seenNamesInFile . has ( name , mode ) ) {
950- stopWatchFailedLookupLocationOfResolution ( resolution , path , getResolutionWithResolvedFileName ) ;
952+ if ( ! resolutionHost . skipWatchingFailedLookups ?.( path ) ) {
953+ stopWatchFailedLookupLocationOfResolution ( resolution , path , getResolutionWithResolvedFileName ) ;
954+ }
951955 resolutionsInFile . delete ( name , mode ) ;
952956 }
953957 } ) ;
@@ -1434,13 +1438,15 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
14341438 // Deleted file, stop watching failed lookups for all the resolutions in the file
14351439 const resolutions = cache . get ( filePath ) ;
14361440 if ( resolutions ) {
1437- resolutions . forEach ( resolution =>
1438- stopWatchFailedLookupLocationOfResolution (
1439- resolution ,
1440- filePath ,
1441- getResolutionWithResolvedFileName ,
1442- )
1443- ) ;
1441+ if ( ! resolutionHost . skipWatchingFailedLookups ?.( filePath ) ) {
1442+ resolutions . forEach ( resolution =>
1443+ stopWatchFailedLookupLocationOfResolution (
1444+ resolution ,
1445+ filePath ,
1446+ getResolutionWithResolvedFileName ,
1447+ )
1448+ ) ;
1449+ }
14441450 cache . delete ( filePath ) ;
14451451 }
14461452 }
0 commit comments