Add explict update methods intead of using spread

This commit is contained in:
Matt Bierner 2020-01-17 14:40:39 -08:00
parent 8714526077
commit 4a5890eabc

View file

@ -52,6 +52,7 @@ namespace ServerState {
export class Running { export class Running {
readonly type = Type.Running; readonly type = Type.Running;
constructor( constructor(
public readonly server: ITypeScriptServer, public readonly server: ITypeScriptServer,
@ -68,6 +69,14 @@ namespace ServerState {
) { } ) { }
public readonly toCancelOnResourceChange = new Set<ToCancelOnResourceChanged>(); public readonly toCancelOnResourceChange = new Set<ToCancelOnResourceChanged>();
updateTsserverVersion(tsserverVersion: string) {
this.tsserverVersion = tsserverVersion;
}
updateLangaugeServiceEnabled(enabled: boolean) {
this.langaugeServiceEnabled = enabled;
}
} }
export class Errored { export class Errored {
@ -759,10 +768,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
{ {
const body = (event as Proto.ProjectLanguageServiceStateEvent).body!; const body = (event as Proto.ProjectLanguageServiceStateEvent).body!;
if (this.serverState.type === ServerState.Type.Running) { if (this.serverState.type === ServerState.Type.Running) {
this.serverState = { this.serverState.updateLangaugeServiceEnabled(body.languageServiceEnabled);
...this.serverState,
langaugeServiceEnabled: body.languageServiceEnabled,
};
} }
this._onProjectLanguageServiceStateChanged.fire(body); this._onProjectLanguageServiceStateChanged.fire(body);
break; break;
@ -831,10 +837,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
} }
if (telemetryData.telemetryEventName === 'projectInfo') { if (telemetryData.telemetryEventName === 'projectInfo') {
if (this.serverState.type === ServerState.Type.Running) { if (this.serverState.type === ServerState.Type.Running) {
this.serverState = { this.serverState.updateTsserverVersion(properties['version']);
...this.serverState,
tsserverVersion: properties['version']
};
} }
} }