mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-30 04:16:48 -05:00
* Add test for #35011 When searching for a default configured project, stop at `node_modules`. * Be more explicit about inferred projects * Move test into tsserver/projects.ts * Use existing helpers to simplify tests
This commit is contained in:
@@ -1590,5 +1590,34 @@ namespace ts.projectSystem {
|
||||
assert.isTrue(e.message.indexOf("Debug Failure. False expression: Found script Info still attached to project") === 0);
|
||||
}
|
||||
});
|
||||
it("does not look beyond node_modules folders for default configured projects", () => {
|
||||
const rootFilePath = server.asNormalizedPath("/project/index.ts");
|
||||
const rootProjectPath = server.asNormalizedPath("/project/tsconfig.json");
|
||||
const nodeModulesFilePath1 = server.asNormalizedPath("/project/node_modules/@types/a/index.d.ts");
|
||||
const nodeModulesProjectPath1 = server.asNormalizedPath("/project/node_modules/@types/a/tsconfig.json");
|
||||
const nodeModulesFilePath2 = server.asNormalizedPath("/project/node_modules/@types/b/index.d.ts");
|
||||
const serverHost = createServerHost([
|
||||
{ path: rootFilePath, content: "import 'a'; import 'b';" },
|
||||
{ path: rootProjectPath, content: "{}" },
|
||||
{ path: nodeModulesFilePath1, content: "{}" },
|
||||
{ path: nodeModulesProjectPath1, content: "{}" },
|
||||
{ path: nodeModulesFilePath2, content: "{}" },
|
||||
]);
|
||||
const projectService = createProjectService(serverHost, { useSingleInferredProject: true });
|
||||
|
||||
const openRootFileResult = projectService.openClientFile(rootFilePath);
|
||||
assert.strictEqual(openRootFileResult.configFileName?.toString(), rootProjectPath);
|
||||
|
||||
const openNodeModulesFileResult1 = projectService.openClientFile(nodeModulesFilePath1);
|
||||
assert.strictEqual(openNodeModulesFileResult1.configFileName?.toString(), nodeModulesProjectPath1);
|
||||
|
||||
const openNodeModulesFileResult2 = projectService.openClientFile(nodeModulesFilePath2);
|
||||
assert.isUndefined(openNodeModulesFileResult2.configFileName);
|
||||
|
||||
const rootProject = projectService.findProject(rootProjectPath)!;
|
||||
checkProjectActualFiles(rootProject, [rootProjectPath, rootFilePath, nodeModulesFilePath1, nodeModulesFilePath2]);
|
||||
|
||||
checkNumberOfInferredProjects(projectService, 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user