Skip to content

Commit

Permalink
more strictFunctions #81574
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Feb 12, 2020
1 parent 48e5c5b commit ddf6ed3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
21 changes: 13 additions & 8 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,14 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
onDidChangeWindowState(listener, thisArg?, disposables?) {
return extHostWindow.onDidChangeWindowState(listener, thisArg, disposables);
},
showInformationMessage(message: string, first: vscode.MessageOptions | string | vscode.MessageItem, ...rest: Array<string | vscode.MessageItem>) {
return extHostMessageService.showMessage(extension, Severity.Info, message, first, rest);
showInformationMessage(message: string, ...rest: Array<vscode.MessageOptions | string | vscode.MessageItem>) {
return <Thenable<any>>extHostMessageService.showMessage(extension, Severity.Info, message, rest[0], <Array<string | vscode.MessageItem>>rest.slice(1));
},
showWarningMessage(message: string, first: vscode.MessageOptions | string | vscode.MessageItem, ...rest: Array<string | vscode.MessageItem>) {
return extHostMessageService.showMessage(extension, Severity.Warning, message, first, rest);
showWarningMessage(message: string, ...rest: Array<vscode.MessageOptions | string | vscode.MessageItem>) {
return <Thenable<any>>extHostMessageService.showMessage(extension, Severity.Warning, message, rest[0], <Array<string | vscode.MessageItem>>rest.slice(1));
},
showErrorMessage(message: string, first: vscode.MessageOptions | string | vscode.MessageItem, ...rest: Array<string | vscode.MessageItem>) {
return extHostMessageService.showMessage(extension, Severity.Error, message, first, rest);
showErrorMessage(message: string, ...rest: Array<vscode.MessageOptions | string | vscode.MessageItem>) {
return <Thenable<any>>extHostMessageService.showMessage(extension, Severity.Error, message, rest[0], <Array<string | vscode.MessageItem>>rest.slice(1));
},
showQuickPick(items: any, options?: vscode.QuickPickOptions, token?: vscode.CancellationToken): any {
return extHostQuickOpen.showQuickPick(items, !!extension.enableProposedApi, options, token);
Expand Down Expand Up @@ -533,7 +533,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
createOutputChannel(name: string): vscode.OutputChannel {
return extHostOutputService.createOutputChannel(name);
},
createWebviewPanel(viewType: string, title: string, showOptions: vscode.ViewColumn | { viewColumn: vscode.ViewColumn, preserveFocus?: boolean }, options: vscode.WebviewPanelOptions & vscode.WebviewOptions): vscode.WebviewPanel {
createWebviewPanel(viewType: string, title: string, showOptions: vscode.ViewColumn | { viewColumn: vscode.ViewColumn, preserveFocus?: boolean }, options?: vscode.WebviewPanelOptions & vscode.WebviewOptions): vscode.WebviewPanel {
return extHostWebviews.createWebviewPanel(extension, viewType, title, showOptions, options);
},
createWebviewTextEditorInset(editor: vscode.TextEditor, line: number, height: number, options?: vscode.WebviewOptions): vscode.WebviewEditorInset {
Expand Down Expand Up @@ -751,7 +751,12 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
},
openTunnel: (forward: vscode.TunnelOptions) => {
checkProposedApiEnabled(extension);
return extHostTunnelService.openTunnel(forward);
return extHostTunnelService.openTunnel(forward).then(value => {
if (!value) {
throw new Error('cannot open tunnel');
}
return value;
});
},
get tunnels() {
checkProposedApiEnabled(extension);
Expand Down
9 changes: 5 additions & 4 deletions src/vs/workbench/api/common/extHostMessageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ export class ExtHostMessageService {
this._proxy = mainContext.getProxy(MainContext.MainThreadMessageService);
}

showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | string, rest: string[]): Promise<string | undefined>;
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | vscode.MessageItem, rest: vscode.MessageItem[]): Promise<vscode.MessageItem | undefined>;
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | vscode.MessageItem | string, rest: Array<vscode.MessageItem | string>): Promise<string | vscode.MessageItem | undefined>;
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | string | vscode.MessageItem, rest: Array<string | vscode.MessageItem>): Promise<string | vscode.MessageItem | undefined> {

showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | string | undefined, rest: string[]): Promise<string | undefined>;
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | vscode.MessageItem | undefined, rest: vscode.MessageItem[]): Promise<vscode.MessageItem | undefined>;
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | vscode.MessageItem | string | undefined, rest: Array<vscode.MessageItem | string>): Promise<string | vscode.MessageItem | undefined>;
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | string | vscode.MessageItem | undefined, rest: Array<string | vscode.MessageItem>): Promise<string | vscode.MessageItem | undefined> {

const options: MainThreadMessageOptions = { extension };
let items: (string | vscode.MessageItem)[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class OutlineModel extends QuickOpenModel {
const searchValuePos = searchValue.indexOf(SCOPE_PREFIX) === 0 ? 1 : 0;

// Check for match and update visibility and group label
this.entries.forEach((entry: SymbolEntry) => {
(<Array<SymbolEntry>>this.entries).forEach(entry => {

// Clear all state first
entry.setGroupLabel(undefined);
Expand All @@ -98,7 +98,7 @@ class OutlineModel extends QuickOpenModel {
});

// select comparator based on the presence of the colon-prefix
this.entries.sort(searchValuePos === 0
(<Array<SymbolEntry>>this.entries).sort(searchValuePos === 0
? SymbolEntry.compareByRank
: SymbolEntry.compareByKindAndRank
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function isItem(i: QuickPickInput<ThemeItem>): i is ThemeItem {
}

function toEntries(themes: Array<IColorTheme | IFileIconTheme>, label?: string): QuickPickInput<ThemeItem>[] {
const toEntry = (theme: IColorTheme): ThemeItem => ({ id: theme.id, label: theme.label, description: theme.description });
const toEntry = (theme: IColorTheme | IFileIconTheme): ThemeItem => ({ id: theme.id, label: theme.label, description: theme.description });
const sorter = (t1: ThemeItem, t2: ThemeItem) => t1.label.localeCompare(t2.label);
let entries: QuickPickInput<ThemeItem>[] = themes.map(toEntry).sort(sorter);
if (entries.length > 0 && label) {
Expand Down

0 comments on commit ddf6ed3

Please sign in to comment.