From 57561ecbc5498826d9ce05a45873f69b0e8a0aa9 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 12 Dec 2018 08:06:54 +0100 Subject: [PATCH] fix strict null --- .../windows/electron-main/windowsService.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/vs/platform/windows/electron-main/windowsService.ts b/src/vs/platform/windows/electron-main/windowsService.ts index 67c2556918d..fd3bd7688b9 100644 --- a/src/vs/platform/windows/electron-main/windowsService.ts +++ b/src/vs/platform/windows/electron-main/windowsService.ts @@ -87,19 +87,19 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable async showMessageBox(windowId: number, options: Electron.MessageBoxOptions): Promise { this.logService.trace('windowsService#showMessageBox', windowId); - return this.withWindow(windowId, codeWindow => this.windowsMainService.showMessageBox(options, codeWindow), () => this.windowsMainService.showMessageBox(options)); + return this.withWindow(windowId, codeWindow => this.windowsMainService.showMessageBox(options, codeWindow), () => this.windowsMainService.showMessageBox(options))!; } async showSaveDialog(windowId: number, options: Electron.SaveDialogOptions): Promise { this.logService.trace('windowsService#showSaveDialog', windowId); - return this.withWindow(windowId, codeWindow => this.windowsMainService.showSaveDialog(options, codeWindow), () => this.windowsMainService.showSaveDialog(options)); + return this.withWindow(windowId, codeWindow => this.windowsMainService.showSaveDialog(options, codeWindow), () => this.windowsMainService.showSaveDialog(options))!; } async showOpenDialog(windowId: number, options: Electron.OpenDialogOptions): Promise { this.logService.trace('windowsService#showOpenDialog', windowId); - return this.withWindow(windowId, codeWindow => this.windowsMainService.showOpenDialog(options, codeWindow), () => this.windowsMainService.showOpenDialog(options)); + return this.withWindow(windowId, codeWindow => this.windowsMainService.showOpenDialog(options, codeWindow), () => this.windowsMainService.showOpenDialog(options))!; } async reloadWindow(windowId: number, args: ParsedArgs): TPromise { @@ -190,7 +190,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable async getRecentlyOpened(windowId: number): TPromise { this.logService.trace('windowsService#getRecentlyOpened', windowId); - return this.withWindow(windowId, codeWindow => this.historyService.getRecentlyOpened(codeWindow.config.workspace || codeWindow.config.folderUri, codeWindow.config.filesToOpen), () => this.historyService.getRecentlyOpened()); + return this.withWindow(windowId, codeWindow => this.historyService.getRecentlyOpened(codeWindow.config.workspace || codeWindow.config.folderUri, codeWindow.config.filesToOpen), () => this.historyService.getRecentlyOpened())!; } async newWindowTab(): TPromise { @@ -244,13 +244,13 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable async isFocused(windowId: number): TPromise { this.logService.trace('windowsService#isFocused', windowId); - return this.withWindow(windowId, codeWindow => codeWindow.win.isFocused(), () => false); + return this.withWindow(windowId, codeWindow => codeWindow.win.isFocused(), () => false)!; } async isMaximized(windowId: number): TPromise { this.logService.trace('windowsService#isMaximized', windowId); - return this.withWindow(windowId, codeWindow => codeWindow.win.isMaximized(), () => false); + return this.withWindow(windowId, codeWindow => codeWindow.win.isMaximized(), () => false)!; } async maximizeWindow(windowId: number): TPromise { @@ -457,7 +457,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable }); } - private withWindow(windowId: number, fn: (window: ICodeWindow) => T, fallback?: () => T): T { + private withWindow(windowId: number, fn: (window: ICodeWindow) => T, fallback?: () => T): T | undefined { const codeWindow = this.windowsMainService.getWindowById(windowId); if (codeWindow) { return fn(codeWindow); -- GitLab