Strict null contrib/webview (#11921)

* strict null contrib/webview

* fix compile
This commit is contained in:
Anthony Dresser
2020-08-21 23:04:29 -07:00
committed by GitHub
parent 9133bef329
commit 91065ebc38
3 changed files with 19 additions and 18 deletions

View File

@@ -48,12 +48,12 @@ export class MainThreadModalDialog implements MainThreadModalDialogShape {
$setTitle(handle: number, value: string): void { $setTitle(handle: number, value: string): void {
const dialog = this._dialogs.get(handle); const dialog = this._dialogs.get(handle);
dialog.headerTitle = value; dialog.setHeaderTitle(value);
} }
$setHtml(handle: number, value: string): void { $setHtml(handle: number, value: string): void {
const dialog = this._dialogs.get(handle); const dialog = this._dialogs.get(handle);
dialog.html = value; dialog.setHtml(value);
} }
$show(handle: number): void { $show(handle: number): void {

View File

@@ -12,7 +12,6 @@ import { Event, Emitter } from 'vs/base/common/event';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { toDisposable } from 'vs/base/common/lifecycle';
import * as DOM from 'vs/base/browser/dom'; import * as DOM from 'vs/base/browser/dom';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { IWebviewService, WebviewElement } from 'vs/workbench/contrib/webview/browser/webview'; import { IWebviewService, WebviewElement } from 'vs/workbench/contrib/webview/browser/webview';
@@ -24,13 +23,13 @@ import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
export class WebViewDialog extends Modal { export class WebViewDialog extends Modal {
private _body: HTMLElement; private _body?: HTMLElement;
private _okButton: Button; private _okButton?: Button;
private _okLabel: string; private _okLabel: string;
private _closeLabel: string; private _closeLabel: string;
private _webview: WebviewElement; private _webview?: WebviewElement;
private _html: string; private _html?: string;
private _headerTitle: string; private _headerTitle?: string;
private _onOk = new Emitter<void>(); private _onOk = new Emitter<void>();
public onOk: Event<void> = this._onOk.event; public onOk: Event<void> = this._onOk.event;
@@ -55,11 +54,11 @@ export class WebViewDialog extends Modal {
this._closeLabel = localize('webViewDialog.close', "Close"); this._closeLabel = localize('webViewDialog.close', "Close");
} }
public set html(value: string) { public setHtml(value: string) {
this._html = value; this._html = value;
} }
public get html(): string { public get html(): string | undefined {
return this._html; return this._html;
} }
@@ -79,11 +78,11 @@ export class WebViewDialog extends Modal {
return this._closeLabel; return this._closeLabel;
} }
public set headerTitle(value: string) { public setHeaderTitle(value: string) {
this._headerTitle = value; this._headerTitle = value;
} }
public get headerTitle(): string { public get headerTitle(): string | undefined {
return this._headerTitle; return this._headerTitle;
} }
@@ -101,7 +100,6 @@ export class WebViewDialog extends Modal {
this._register(this._webview.onMessage(message => this._onMessage.fire(message))); this._register(this._webview.onMessage(message => this._onMessage.fire(message)));
this._register(this._webview); this._register(this._webview);
this._register(toDisposable(() => this._webview = null));
} }
get onMessage(): Event<any> { get onMessage(): Event<any> {
@@ -121,7 +119,9 @@ export class WebViewDialog extends Modal {
} }
private updateDialogBody(): void { private updateDialogBody(): void {
this._webview.html = this.html; if (this.html) {
this._webview!.html = this.html;
}
} }
/* espace key */ /* espace key */
@@ -145,13 +145,15 @@ export class WebViewDialog extends Modal {
} }
public sendMessage(message: any): void { public sendMessage(message: any): void {
this._webview.postMessage(message); if (this._webview) {
this._webview.postMessage(message);
}
} }
public open() { public open() {
this.title = this.headerTitle; this.title = this.headerTitle ?? '';
this.updateDialogBody(); this.updateDialogBody();
this.show(); this.show();
this._okButton.focus(); this._okButton!.focus();
} }
} }

View File

@@ -56,7 +56,6 @@
"./sql/workbench/contrib/scripting/**/*.ts", // 280 errors "./sql/workbench/contrib/scripting/**/*.ts", // 280 errors
"./sql/workbench/contrib/tasks/**/*.ts", // 100 errors "./sql/workbench/contrib/tasks/**/*.ts", // 100 errors
"./sql/workbench/contrib/views/**/*.ts", // 133 errors "./sql/workbench/contrib/views/**/*.ts", // 133 errors
"./sql/workbench/contrib/webview/**/*.ts", // 6 errors
"./sql/workbench/contrib/welcome/**/*.ts", // 66 errors "./sql/workbench/contrib/welcome/**/*.ts", // 66 errors
"./sql/workbench/services/connection/**/*.ts", // 3402 errors "./sql/workbench/services/connection/**/*.ts", // 3402 errors
"./sql/workbench/services/dialog/**/*.ts", // 3260 errors "./sql/workbench/services/dialog/**/*.ts", // 3260 errors