@@ -1590,5 +1590,34 @@ namespace ts.projectSystem {
1590
1590
assert . isTrue ( e . message . indexOf ( "Debug Failure. False expression: Found script Info still attached to project" ) === 0 ) ;
1591
1591
}
1592
1592
} ) ;
1593
+ it ( "does not look beyond node_modules folders for default configured projects" , ( ) => {
1594
+ const rootFilePath = server . asNormalizedPath ( "/project/index.ts" ) ;
1595
+ const rootProjectPath = server . asNormalizedPath ( "/project/tsconfig.json" ) ;
1596
+ const nodeModulesFilePath1 = server . asNormalizedPath ( "/project/node_modules/@types/a/index.d.ts" ) ;
1597
+ const nodeModulesProjectPath1 = server . asNormalizedPath ( "/project/node_modules/@types/a/tsconfig.json" ) ;
1598
+ const nodeModulesFilePath2 = server . asNormalizedPath ( "/project/node_modules/@types/b/index.d.ts" ) ;
1599
+ const serverHost = createServerHost ( [
1600
+ { path : rootFilePath , content : "import 'a'; import 'b';" } ,
1601
+ { path : rootProjectPath , content : "{}" } ,
1602
+ { path : nodeModulesFilePath1 , content : "{}" } ,
1603
+ { path : nodeModulesProjectPath1 , content : "{}" } ,
1604
+ { path : nodeModulesFilePath2 , content : "{}" } ,
1605
+ ] ) ;
1606
+ const projectService = createProjectService ( serverHost , { useSingleInferredProject : true } ) ;
1607
+
1608
+ const openRootFileResult = projectService . openClientFile ( rootFilePath ) ;
1609
+ assert . strictEqual ( openRootFileResult . configFileName ?. toString ( ) , rootProjectPath ) ;
1610
+
1611
+ const openNodeModulesFileResult1 = projectService . openClientFile ( nodeModulesFilePath1 ) ;
1612
+ assert . strictEqual ( openNodeModulesFileResult1 . configFileName ?. toString ( ) , nodeModulesProjectPath1 ) ;
1613
+
1614
+ const openNodeModulesFileResult2 = projectService . openClientFile ( nodeModulesFilePath2 ) ;
1615
+ assert . isUndefined ( openNodeModulesFileResult2 . configFileName ) ;
1616
+
1617
+ const rootProject = projectService . findProject ( rootProjectPath ) ! ;
1618
+ checkProjectActualFiles ( rootProject , [ rootProjectPath , rootFilePath , nodeModulesFilePath1 , nodeModulesFilePath2 ] ) ;
1619
+
1620
+ checkNumberOfInferredProjects ( projectService , 0 ) ;
1621
+ } ) ;
1593
1622
} ) ;
1594
1623
}
0 commit comments