Strict null work for quick input

This commit is contained in:
Matt Bierner
2019-02-14 12:54:42 -08:00
parent 10c3e9d285
commit 52f8705214
4 changed files with 13 additions and 13 deletions

View File

@@ -939,7 +939,7 @@ export interface ExtHostLanguageFeaturesShape {
export interface ExtHostQuickOpenShape {
$onItemSelected(handle: number): void;
$validateInput(input: string): Promise<string>;
$validateInput(input: string): Promise<string | null | undefined>;
$onDidChangeActive(sessionId: number, handles: number[]): void;
$onDidChangeSelection(sessionId: number, handles: number[]): void;
$onDidAccept(sessionId: number): void;

View File

@@ -25,7 +25,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
private _commands: ExtHostCommands;
private _onDidSelectItem: (handle: number) => void;
private _validateInput: (input: string) => string | Thenable<string>;
private _validateInput?: (input: string) => string | undefined | null | Thenable<string | undefined | null>;
private _sessions = new Map<number, ExtHostQuickInput>();
@@ -72,10 +72,10 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
let item = items[handle];
let label: string;
let description: string;
let detail: string;
let picked: boolean;
let alwaysShow: boolean;
let description: string | undefined;
let detail: string | undefined;
let picked: boolean | undefined;
let alwaysShow: boolean | undefined;
if (typeof item === 'string') {
label = item;
@@ -99,7 +99,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
// handle selection changes
if (options && typeof options.onDidSelectItem === 'function') {
this._onDidSelectItem = (handle) => {
options.onDidSelectItem(items[handle]);
options.onDidSelectItem!(items[handle]);
};
}
@@ -137,7 +137,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
showInput(options?: InputBoxOptions, token: CancellationToken = CancellationToken.None): Promise<string> {
// global validate fn used in callback below
this._validateInput = options && options.validateInput;
this._validateInput = options ? options.validateInput : undefined;
return this._proxy.$input(options, typeof this._validateInput === 'function', token)
.then(undefined, err => {
@@ -149,11 +149,11 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
});
}
$validateInput(input: string): Promise<string> {
$validateInput(input: string): Promise<string | null | undefined> {
if (this._validateInput) {
return asPromise(() => this._validateInput(input));
return asPromise(() => this._validateInput!(input));
}
return undefined;
return Promise.resolve(undefined);
}
// ---- workspace folder picker