File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2387,4 +2387,26 @@ namespace ts.projectSystem {
23872387 assert . isTrue ( errorResult . length === 0 ) ;
23882388 } ) ;
23892389 } ) ;
2390+
2391+ describe ( "maxNodeModuleJsDepth for inferred projects" , ( ) => {
2392+ it ( "should be set by default" , ( ) => {
2393+ const file1 : FileOrFolder = {
2394+ path : "/a/b/file1.js" ,
2395+ content : `var t = require("test"); t.`
2396+ } ;
2397+ const moduleFile : FileOrFolder = {
2398+ path : "/a/b/node_modules/test/index.js" ,
2399+ content : `var v = 10; module.exports = v;`
2400+ } ;
2401+
2402+ const host = createServerHost ( [ file1 , moduleFile ] ) ;
2403+ const projectService = createProjectService ( host ) ;
2404+ projectService . openClientFile ( file1 . path ) ;
2405+
2406+ const project = projectService . inferredProjects [ 0 ] ;
2407+ const sourceFile = project . getSourceFile ( < Path > file1 . path ) ;
2408+ assert . isTrue ( "test" in sourceFile . resolvedModules ) ;
2409+ assert . equal ( ( < ResolvedModule > sourceFile . resolvedModules [ "test" ] ) . resolvedFileName , moduleFile . path ) ;
2410+ } ) ;
2411+ } ) ;
23902412}
Original file line number Diff line number Diff line change @@ -126,6 +126,13 @@ namespace ts.server {
126126 this . compilerOptions . allowNonTsExtensions = true ;
127127 }
128128
129+ if ( this . projectKind === ProjectKind . Inferred ) {
130+ // Add default compiler options for inferred projects here
131+ if ( this . compilerOptions . maxNodeModuleJsDepth === undefined ) {
132+ this . compilerOptions . maxNodeModuleJsDepth = 2 ;
133+ }
134+ }
135+
129136 if ( languageServiceEnabled ) {
130137 this . enableLanguageService ( ) ;
131138 }
You can’t perform that action at this time.
0 commit comments