Use ?. in a few more places

This commit is contained in:
Matt Bierner 2022-02-01 13:44:57 -08:00
parent c3a004ea9b
commit 90b50dc7e2
No known key found for this signature in database
GPG key ID: 099C331567E11888
5 changed files with 8 additions and 20 deletions

View file

@ -8,9 +8,7 @@ import * as vscode from 'vscode';
export function disposeAll(disposables: vscode.Disposable[]) {
while (disposables.length) {
const item = disposables.pop();
if (item) {
item.dispose();
}
item?.dispose();
}
}
@ -39,4 +37,4 @@ export abstract class Disposable {
protected get isDisposed() {
return this._isDisposed;
}
}
}

View file

@ -8,9 +8,7 @@ import * as vscode from 'vscode';
export function disposeAll(disposables: vscode.Disposable[]) {
while (disposables.length) {
const item = disposables.pop();
if (item) {
item.dispose();
}
item?.dispose();
}
}

View file

@ -186,9 +186,7 @@ export class ProcessBasedTsServer extends Disposable implements ITypeScriptServe
return false;
} finally {
const callback = this.fetchCallback(seq);
if (callback) {
callback.onSuccess(new ServerResponse.Cancelled(`Cancelled request ${seq} - ${command}`));
}
callback?.onSuccess(new ServerResponse.Cancelled(`Cancelled request ${seq} - ${command}`));
}
}
@ -273,9 +271,7 @@ export class ProcessBasedTsServer extends Disposable implements ITypeScriptServe
this.write(serverRequest);
} catch (err) {
const callback = this.fetchCallback(serverRequest.seq);
if (callback) {
callback.onError(err);
}
callback?.onError(err);
}
}

View file

@ -46,9 +46,7 @@ export class Delayer<T> {
if (delay >= 0 || this.timeout === null) {
this.timeout = setTimeout(() => {
this.timeout = null;
if (this.onSuccess) {
this.onSuccess(undefined);
}
this.onSuccess?.(undefined);
}, delay >= 0 ? delay : this.defaultDelay);
}

View file

@ -8,9 +8,7 @@ import * as vscode from 'vscode';
export function disposeAll(disposables: vscode.Disposable[]) {
while (disposables.length) {
const item = disposables.pop();
if (item) {
item.dispose();
}
item?.dispose();
}
}
@ -39,4 +37,4 @@ export abstract class Disposable {
protected get isDisposed() {
return this._isDisposed;
}
}
}