File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -2387,4 +2387,26 @@ namespace ts.projectSystem {
2387
2387
assert . isTrue ( errorResult . length === 0 ) ;
2388
2388
} ) ;
2389
2389
} ) ;
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
+ } ) ;
2390
2412
}
Original file line number Diff line number Diff line change @@ -126,6 +126,13 @@ namespace ts.server {
126
126
this . compilerOptions . allowNonTsExtensions = true ;
127
127
}
128
128
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
+
129
136
if ( languageServiceEnabled ) {
130
137
this . enableLanguageService ( ) ;
131
138
}
You can’t perform that action at this time.
0 commit comments