@@ -975,5 +975,33 @@ export const x = 10;`
975
975
host . checkTimeoutQueueLength ( 0 ) ;
976
976
} ) ;
977
977
} ) ;
978
+
979
+ describe ( "avoid unnecessary invalidation" , ( ) => {
980
+ it ( "failed lookup invalidation" , ( ) => {
981
+ const expectedNonRelativeDirectories = [ `${ projectLocation } /node_modules` , `${ projectLocation } /src` ] ;
982
+ const module1Name = "module1" ;
983
+ const module2Name = "module2" ;
984
+ const fileContent = `import { module1 } from "${ module1Name } ";import { module2 } from "${ module2Name } ";` ;
985
+ const file1 : File = {
986
+ path : `${ projectLocation } /src/file1.ts` ,
987
+ content : fileContent
988
+ } ;
989
+ const { module1, module2 } = getModules ( `${ projectLocation } /src/node_modules/module1/index.ts` , `${ projectLocation } /node_modules/module2/index.ts` ) ;
990
+ const files = [ module1 , module2 , file1 , configFile , libFile ] ;
991
+ const host = createServerHost ( files ) ;
992
+ const resolutionTrace = createHostModuleResolutionTrace ( host ) ;
993
+ const service = createProjectService ( host ) ;
994
+ service . openClientFile ( file1 . path ) ;
995
+ const project = service . configuredProjects . get ( configFile . path ) ! ;
996
+ ( project as ResolutionCacheHost ) . maxNumberOfFilesToIterateForInvalidation = 1 ;
997
+ const expectedTrace = getExpectedNonRelativeModuleResolutionTrace ( host , file1 , module1 , module1Name ) ;
998
+ getExpectedNonRelativeModuleResolutionTrace ( host , file1 , module2 , module2Name , expectedTrace ) ;
999
+ verifyTrace ( resolutionTrace , expectedTrace ) ;
1000
+ verifyWatchesWithConfigFile ( host , files , file1 , expectedNonRelativeDirectories ) ;
1001
+
1002
+ host . invokeWatchedDirectoriesRecursiveCallback ( projectLocation + "/src" , "file1.ts" ) ;
1003
+ host . checkTimeoutQueueLengthAndRun ( 0 ) ;
1004
+ } ) ;
1005
+ } ) ;
978
1006
} ) ;
979
1007
}
0 commit comments