Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/testRunner/unittests/tsserver/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
}