mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-16 05:58:32 -06:00
Set maxNodeModuleJsDepth for inferred projects
This commit is contained in:
parent
31a55e6452
commit
536d703d9e
@ -2387,4 +2387,26 @@ namespace ts.projectSystem {
|
||||
assert.isTrue(errorResult.length === 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("maxNodeModuleJsDepth for inferred projects", () => {
|
||||
it("should be set by default", () => {
|
||||
const file1: FileOrFolder = {
|
||||
path: "/a/b/file1.js",
|
||||
content: `var t = require("test"); t.`
|
||||
};
|
||||
const moduleFile: FileOrFolder = {
|
||||
path: "/a/b/node_modules/test/index.js",
|
||||
content: `var v = 10; module.exports = v;`
|
||||
};
|
||||
|
||||
const host = createServerHost([file1, moduleFile]);
|
||||
const projectService = createProjectService(host);
|
||||
projectService.openClientFile(file1.path);
|
||||
|
||||
const project = projectService.inferredProjects[0];
|
||||
const sourceFile = project.getSourceFile(<Path>file1.path);
|
||||
assert.isTrue("test" in sourceFile.resolvedModules);
|
||||
assert.equal((<ResolvedModule>sourceFile.resolvedModules["test"]).resolvedFileName, moduleFile.path);
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -126,6 +126,13 @@ namespace ts.server {
|
||||
this.compilerOptions.allowNonTsExtensions = true;
|
||||
}
|
||||
|
||||
if (this.projectKind === ProjectKind.Inferred) {
|
||||
// Add default compiler options for inferred projects here
|
||||
if (this.compilerOptions.maxNodeModuleJsDepth === undefined) {
|
||||
this.compilerOptions.maxNodeModuleJsDepth = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (languageServiceEnabled) {
|
||||
this.enableLanguageService();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user