noop in setTypeAcquisiton for undefined (#41291)

* noop in setTypeAcquisiton for undefined

* accept new baseline

* add regression test
This commit is contained in:
Jesse Trinity
2020-10-29 13:30:42 -07:00
committed by GitHub
parent 6bde4b5c02
commit b27d4bf3f6
3 changed files with 27 additions and 4 deletions

View File

@@ -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) };
}
@@ -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() {

View File

@@ -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");
});
});
}

View File

@@ -9307,7 +9307,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;