diff --git a/src/vs/workbench/api/browser/viewsExtensionPoint.ts b/src/vs/workbench/api/browser/viewsExtensionPoint.ts index fbffb5d002f..4674ec350c6 100644 --- a/src/vs/workbench/api/browser/viewsExtensionPoint.ts +++ b/src/vs/workbench/api/browser/viewsExtensionPoint.ts @@ -358,11 +358,11 @@ class ViewsExtensionHandler implements IWorkbenchContribution { return; } - let container = this.getViewContainer(entry.key); - if (!container) { + const viewContainer = this.getViewContainer(entry.key); + if (!viewContainer) { collector.warn(localize('ViewContainerDoesnotExist', "View container '{0}' does not exist and all views registered to it will be added to 'Explorer'.", entry.key)); - container = this.getDefaultViewContainer(); } + const container = viewContainer || this.getDefaultViewContainer(); const registeredViews = ViewsRegistry.getViews(container); const viewIds: string[] = []; const viewDescriptors = coalesce(entry.value.map((item, index) => { @@ -398,7 +398,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution { } private getDefaultViewContainer(): ViewContainer { - return this.viewContainersRegistry.get(EXPLORER); + return this.viewContainersRegistry.get(EXPLORER)!; } private removeViews(extensions: IExtensionPointUser[]): void { @@ -435,7 +435,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution { return true; } - private getViewContainer(value: string): ViewContainer { + private getViewContainer(value: string): ViewContainer | undefined { switch (value) { case 'explorer': return this.viewContainersRegistry.get(EXPLORER); case 'debug': return this.viewContainersRegistry.get(DEBUG); diff --git a/src/vs/workbench/api/node/apiCommands.ts b/src/vs/workbench/api/node/apiCommands.ts index 0e808dbfed4..b6691b812d1 100644 --- a/src/vs/workbench/api/node/apiCommands.ts +++ b/src/vs/workbench/api/node/apiCommands.ts @@ -27,7 +27,7 @@ import { generateUuid } from 'vs/base/common/uuid'; // ----------------------------------------------------------------- export interface ICommandsExecutor { - executeCommand(id: string, ...args: any[]): Promise; + executeCommand(id: string, ...args: any[]): Promise; } function adjustHandler(handler: (executor: ICommandsExecutor, ...args: any[]) => any): ICommandHandler { @@ -84,8 +84,8 @@ CommandsRegistry.registerCommand(DiffAPICommand.ID, adjustHandler(DiffAPICommand export class OpenAPICommand { public static ID = 'vscode.open'; public static execute(executor: ICommandsExecutor, resource: URI, columnOrOptions?: vscode.ViewColumn | vscode.TextDocumentShowOptions, label?: string): Promise { - let options: ITextEditorOptions; - let position: EditorViewColumn; + let options: ITextEditorOptions | undefined; + let position: EditorViewColumn | undefined; if (columnOrOptions) { if (typeof columnOrOptions === 'number') { diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 93bf62e21a9..a66f695c65c 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -102,7 +102,7 @@ export interface MainThreadClipboardShape extends IDisposable { export interface MainThreadCommandsShape extends IDisposable { $registerCommand(id: string): void; $unregisterCommand(id: string): void; - $executeCommand(id: string, args: any[]): Promise; + $executeCommand(id: string, args: any[]): Promise; $getCommands(): Promise; } diff --git a/src/vs/workbench/api/node/extHostConfiguration.ts b/src/vs/workbench/api/node/extHostConfiguration.ts index 3e73209ffbb..b65cdf1f2bf 100644 --- a/src/vs/workbench/api/node/extHostConfiguration.ts +++ b/src/vs/workbench/api/node/extHostConfiguration.ts @@ -43,7 +43,7 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape { private readonly _proxy: MainThreadConfigurationShape; private readonly _extHostWorkspace: ExtHostWorkspace; private readonly _barrier: Barrier; - private _actual: ExtHostConfigProvider; + private _actual: ExtHostConfigProvider | null; constructor(proxy: MainThreadConfigurationShape, extHostWorkspace: ExtHostWorkspace) { this._proxy = proxy; @@ -53,7 +53,7 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape { } public getConfigProvider(): Promise { - return this._barrier.wait().then(_ => this._actual); + return this._barrier.wait().then(_ => this._actual!); } $initializeConfiguration(data: IConfigurationInitData): void { @@ -93,14 +93,14 @@ export class ExtHostConfigProvider { getConfiguration(section?: string, resource?: URI, extensionId?: ExtensionIdentifier): vscode.WorkspaceConfiguration { const config = this._toReadonlyValue(section - ? lookUp(this._configuration.getValue(null, { resource }, this._extHostWorkspace.workspace), section) - : this._configuration.getValue(null, { resource }, this._extHostWorkspace.workspace)); + ? lookUp(this._configuration.getValue(undefined, { resource }, this._extHostWorkspace.workspace), section) + : this._configuration.getValue(undefined, { resource }, this._extHostWorkspace.workspace)); if (section) { this._validateConfigurationAccess(section, resource, extensionId); } - function parseConfigurationTarget(arg: boolean | ExtHostConfigurationTarget): ConfigurationTarget { + function parseConfigurationTarget(arg: boolean | ExtHostConfigurationTarget): ConfigurationTarget | null { if (arg === undefined || arg === null) { return null; } @@ -218,7 +218,7 @@ export class ExtHostConfigProvider { return readonlyProxy(result); } - private _validateConfigurationAccess(key: string, resource: URI, extensionId: ExtensionIdentifier): void { + private _validateConfigurationAccess(key: string, resource: URI | undefined, extensionId: ExtensionIdentifier): void { const scope = OVERRIDE_PROPERTY_PATTERN.test(key) ? ConfigurationScope.RESOURCE : this._configurationScopes[key]; const extensionIdText = extensionId ? `[${extensionId.value}] ` : ''; if (ConfigurationScope.RESOURCE === scope) { diff --git a/src/vs/workbench/api/node/extHostFileSystemEventService.ts b/src/vs/workbench/api/node/extHostFileSystemEventService.ts index c42b36dd383..f7f682b6281 100644 --- a/src/vs/workbench/api/node/extHostFileSystemEventService.ts +++ b/src/vs/workbench/api/node/extHostFileSystemEventService.ts @@ -163,7 +163,7 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ bucket.push(wrappedThenable); } }; - }).then(() => { + }).then((): any => { if (edits.length === 0) { return undefined; } diff --git a/src/vs/workbench/api/node/extHostMessageService.ts b/src/vs/workbench/api/node/extHostMessageService.ts index f24be5f48b0..ea85d1d6d99 100644 --- a/src/vs/workbench/api/node/extHostMessageService.ts +++ b/src/vs/workbench/api/node/extHostMessageService.ts @@ -42,7 +42,7 @@ export class ExtHostMessageService { commands.push({ title: command, handle, isCloseAffordance: false }); } else if (typeof command === 'object') { let { title, isCloseAffordance } = command; - commands.push({ title, isCloseAffordance, handle }); + commands.push({ title, isCloseAffordance: !!isCloseAffordance, handle }); } else { console.warn('Invalid message item:', command); } diff --git a/src/vs/workbench/api/node/extHostStorage.ts b/src/vs/workbench/api/node/extHostStorage.ts index 8925cdbb4d0..32df5a99877 100644 --- a/src/vs/workbench/api/node/extHostStorage.ts +++ b/src/vs/workbench/api/node/extHostStorage.ts @@ -23,7 +23,7 @@ export class ExtHostStorage implements ExtHostStorageShape { this._proxy = mainContext.getProxy(MainContext.MainThreadStorage); } - getValue(shared: boolean, key: string, defaultValue?: T): Promise { + getValue(shared: boolean, key: string, defaultValue?: T): Promise { return this._proxy.$getValue(shared, key).then(value => value || defaultValue); } diff --git a/src/vs/workbench/api/node/extHostWebview.ts b/src/vs/workbench/api/node/extHostWebview.ts index a39904bd0ff..0906dd92aad 100644 --- a/src/vs/workbench/api/node/extHostWebview.ts +++ b/src/vs/workbench/api/node/extHostWebview.ts @@ -80,7 +80,7 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel { private readonly _proxy: MainThreadWebviewsShape; private readonly _viewType: string; private _title: string; - private _iconPath: IconPath; + private _iconPath?: IconPath; private readonly _options: vscode.WebviewPanelOptions; private readonly _webview: ExtHostWebview; diff --git a/src/vs/workbench/common/editor/textDiffEditorModel.ts b/src/vs/workbench/common/editor/textDiffEditorModel.ts index fda5a788dd6..3b9c750f528 100644 --- a/src/vs/workbench/common/editor/textDiffEditorModel.ts +++ b/src/vs/workbench/common/editor/textDiffEditorModel.ts @@ -13,7 +13,7 @@ import { DiffEditorModel } from 'vs/workbench/common/editor/diffEditorModel'; * and the modified version. */ export class TextDiffEditorModel extends DiffEditorModel { - private _textDiffEditorModel: IDiffEditorModel; + private _textDiffEditorModel: IDiffEditorModel | null; constructor(originalModel: BaseTextEditorModel, modifiedModel: BaseTextEditorModel) { super(originalModel, modifiedModel); @@ -56,7 +56,7 @@ export class TextDiffEditorModel extends DiffEditorModel { } } - get textDiffEditorModel(): IDiffEditorModel { + get textDiffEditorModel(): IDiffEditorModel | null { return this._textDiffEditorModel; } diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 1e6333c7314..1a7ba1c6ca0 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -164,7 +164,7 @@ function createWorkspaceInitializationPayload(configuration: IWindowConfiguratio } // Single-folder workspace - let workspaceInitializationPayload: Promise = Promise.resolve(); + let workspaceInitializationPayload: Promise = Promise.resolve(); if (configuration.folderUri) { workspaceInitializationPayload = resolveSingleFolderWorkspaceInitializationPayload(configuration.folderUri); } @@ -189,7 +189,7 @@ function createWorkspaceInitializationPayload(configuration: IWindowConfiguratio }); } -function resolveSingleFolderWorkspaceInitializationPayload(folderUri: ISingleFolderWorkspaceIdentifier): Promise { +function resolveSingleFolderWorkspaceInitializationPayload(folderUri: ISingleFolderWorkspaceIdentifier): Promise { // Return early the folder is not local if (folderUri.scheme !== Schemas.file) { @@ -197,7 +197,7 @@ function resolveSingleFolderWorkspaceInitializationPayload(folderUri: ISingleFol } function computeLocalDiskFolderId(folder: uri, stat: fs.Stats): string { - let ctime: number; + let ctime: number | undefined; if (platform.isLinux) { ctime = stat.ino; // Linux: birthtime is ctime, so we cannot use it! We use the ino instead! } else if (platform.isMacintosh) { diff --git a/src/vs/workbench/test/electron-browser/api/testRPCProtocol.ts b/src/vs/workbench/test/electron-browser/api/testRPCProtocol.ts index 4bd240bee45..9e5f7c57d9e 100644 --- a/src/vs/workbench/test/electron-browser/api/testRPCProtocol.ts +++ b/src/vs/workbench/test/electron-browser/api/testRPCProtocol.ts @@ -10,23 +10,23 @@ import { isThenable } from 'vs/base/common/async'; export function SingleProxyRPCProtocol(thing: any): IExtHostContext { return { - remoteAuthority: null, + remoteAuthority: null!, getProxy(): T { return thing; }, set(identifier: ProxyIdentifier, value: R): R { return value; }, - assertRegistered: undefined + assertRegistered: undefined! }; } export class TestRPCProtocol implements IExtHostContext { - public remoteAuthority = null; + public remoteAuthority = null!; private _callCountValue: number = 0; - private _idle: Promise; + private _idle?: Promise; private _completeIdle: Function; private readonly _locals: { [id: string]: any; };