Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions src/server/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,10 @@ namespace ts.server {
return this.projectName;
}

protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition | undefined): TypeAcquisition {
protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition): TypeAcquisition {
if (!newTypeAcquisition || !newTypeAcquisition.include) {
// Nothing to filter out, so just return as-is
return newTypeAcquisition || {};
return newTypeAcquisition;
}
return { ...newTypeAcquisition, include: this.removeExistingTypings(newTypeAcquisition.include) };
}
Expand Down Expand Up @@ -1410,7 +1410,9 @@ namespace ts.server {
}

setTypeAcquisition(newTypeAcquisition: TypeAcquisition | undefined): void {
this.typeAcquisition = this.removeLocalTypingsFromTypeAcquisition(newTypeAcquisition);
if (newTypeAcquisition) {
this.typeAcquisition = this.removeLocalTypingsFromTypeAcquisition(newTypeAcquisition);
}
}

getTypeAcquisition() {
Expand Down
21 changes: 21 additions & 0 deletions src/testRunner/unittests/tsserver/inferredProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,5 +429,26 @@ namespace ts.projectSystem {
configuredRemoved.clear();
}
});

it("regression test - should infer typeAcquisition for inferred projects when set undefined", () => {
const file1 = { path: "/a/file1.js", content: "" };
const host = createServerHost([file1]);

const projectService = createProjectService(host);

projectService.openClientFile(file1.path);

checkNumberOfProjects(projectService, { inferredProjects: 1 });
const inferredProject = projectService.inferredProjects[0];
checkProjectActualFiles(inferredProject, [file1.path]);
inferredProject.setTypeAcquisition(undefined);

const expected = {
enable: true,
include: [],
exclude: []
};
assert.deepEqual(inferredProject.getTypeAcquisition(), expected, "typeAcquisition should be inferred for inferred projects");
});
});
}
2 changes: 1 addition & 1 deletion tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9306,7 +9306,7 @@ declare namespace ts.server {
enableLanguageService(): void;
disableLanguageService(lastFileExceededProgramSize?: string): void;
getProjectName(): string;
protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition | undefined): TypeAcquisition;
protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition): TypeAcquisition;
getExternalFiles(): SortedReadonlyArray<string>;
getSourceFile(path: Path): SourceFile | undefined;
close(): void;
Expand Down