Skip to content

Commit 667751d

Browse files
committed
When sending typings request use project's current directory as project root path
This ensures that we arent picking typings from folder different from the current directory for the project
1 parent 90a1df9 commit 667751d

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6503,7 +6503,7 @@ namespace ts.projectSystem {
65036503
path: `${currentDirectory}/package.json`,
65046504
content: JSON.stringify({
65056505
devDependencies: {
6506-
"pkgcurrentdirectory": ""
6506+
pkgcurrentdirectory: ""
65076507
},
65086508
})
65096509
};
@@ -6555,6 +6555,9 @@ namespace ts.projectSystem {
65556555

65566556
// Ensure that we use result from types cache when getting ls
65576557
assert.isDefined(project.getLanguageService());
6558+
6559+
// Verify that the pkgcurrentdirectory from the current directory isnt picked up
6560+
checkProjectActualFiles(project, [file.path]);
65586561
});
65596562
});
65606563
}

src/server/utilities.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,14 @@ namespace ts.server {
3434
export type Types = Msg;
3535
}
3636

37-
function getProjectRootPath(project: Project): Path {
38-
switch (project.projectKind) {
39-
case ProjectKind.Configured:
40-
return <Path>getDirectoryPath(project.getProjectName());
41-
case ProjectKind.Inferred:
42-
// TODO: fixme
43-
return <Path>"";
44-
case ProjectKind.External:
45-
const projectName = normalizeSlashes(project.getProjectName());
46-
return <Path>getDirectoryPath(projectName);
47-
}
48-
}
49-
5037
export function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings {
5138
return {
5239
projectName: project.getProjectName(),
5340
fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true, /*excludeConfigFiles*/ true).concat(project.getExcludedFiles() as NormalizedPath[]),
5441
compilerOptions: project.getCompilationSettings(),
5542
typeAcquisition,
5643
unresolvedImports,
57-
projectRootPath: getProjectRootPath(project),
44+
projectRootPath: project.getCurrentDirectory() as Path,
5845
cachePath,
5946
kind: "discover"
6047
};

0 commit comments

Comments
 (0)