diff --git a/app/commands.ts b/app/commands.ts index df5a512f..5abce42a 100644 --- a/app/commands.ts +++ b/app/commands.ts @@ -1,12 +1,12 @@ import {app, Menu} from 'electron'; -import type {BaseWindow} from 'electron'; +import type {BaseWindow, BrowserWindow} from 'electron'; import {openConfig, getConfig} from './config'; import {updatePlugins} from './plugins'; import {installCLI} from './utils/cli-install'; import * as systemContextMenu from './utils/system-context-menu'; -const commands: Record void> = { +const commands: Record void> = { 'window:new': () => { // If window is created on the same tick, it will consume event too setTimeout(app.createWindow, 0); @@ -162,7 +162,7 @@ getConfig().profiles.forEach((profile) => { }; }); -export const execCommand = (command: string, focusedWindow?: BaseWindow) => { +export const execCommand = (command: string, focusedWindow?: BrowserWindow) => { const fn = commands[command]; if (fn) { fn(focusedWindow); diff --git a/app/menus/menu.ts b/app/menus/menu.ts index df877e69..140d8b42 100644 --- a/app/menus/menu.ts +++ b/app/menus/menu.ts @@ -65,7 +65,7 @@ export const createMenu = ( ...(process.platform === 'darwin' ? [darwinMenu(commandKeys, execCommand, showAbout)] : []), shellMenu( commandKeys, - execCommand, + (command, focusedWindow) => execCommand(command, focusedWindow as BrowserWindow | undefined), getConfig().profiles.map((p) => p.name) ), editMenu(commandKeys, execCommand), diff --git a/app/menus/menus/view.ts b/app/menus/menus/view.ts index ae2fe1d0..ece82e64 100644 --- a/app/menus/menus/view.ts +++ b/app/menus/menus/view.ts @@ -1,8 +1,8 @@ -import type {BaseWindow, MenuItemConstructorOptions} from 'electron'; +import type {BaseWindow, BrowserWindow, MenuItemConstructorOptions} from 'electron'; const viewMenu = ( commandKeys: Record, - execCommand: (command: string, focusedWindow?: BaseWindow) => void + execCommand: (command: string, focusedWindow?: BrowserWindow) => void ): MenuItemConstructorOptions => { return { label: 'View', @@ -11,21 +11,21 @@ const viewMenu = ( label: 'Reload', accelerator: commandKeys['window:reload'], click(item, focusedWindow) { - execCommand('window:reload', focusedWindow); + execCommand('window:reload', focusedWindow as BrowserWindow); } }, { label: 'Full Reload', accelerator: commandKeys['window:reloadFull'], click(item, focusedWindow) { - execCommand('window:reloadFull', focusedWindow); + execCommand('window:reloadFull', focusedWindow as BrowserWindow); } }, { label: 'Developer Tools', accelerator: commandKeys['window:devtools'], click: (item, focusedWindow) => { - execCommand('window:devtools', focusedWindow); + execCommand('window:devtools', focusedWindow as BrowserWindow); } }, { @@ -35,21 +35,21 @@ const viewMenu = ( label: 'Reset Zoom Level', accelerator: commandKeys['zoom:reset'], click(item, focusedWindow) { - execCommand('zoom:reset', focusedWindow); + execCommand('zoom:reset', focusedWindow as BrowserWindow); } }, { label: 'Zoom In', accelerator: commandKeys['zoom:in'], click(item, focusedWindow) { - execCommand('zoom:in', focusedWindow); + execCommand('zoom:in', focusedWindow as BrowserWindow); } }, { label: 'Zoom Out', accelerator: commandKeys['zoom:out'], click(item, focusedWindow) { - execCommand('zoom:out', focusedWindow); + execCommand('zoom:out', focusedWindow as BrowserWindow); } } ] diff --git a/app/menus/menus/window.ts b/app/menus/menus/window.ts index aad329b1..03c7bf6b 100644 --- a/app/menus/menus/window.ts +++ b/app/menus/menus/window.ts @@ -1,8 +1,8 @@ -import type {BaseWindow, MenuItemConstructorOptions} from 'electron'; +import type {BaseWindow, BrowserWindow, MenuItemConstructorOptions} from 'electron'; const windowMenu = ( commandKeys: Record, - execCommand: (command: string, focusedWindow?: BaseWindow) => void + execCommand: (command: string, focusedWindow?: BrowserWindow) => void ): MenuItemConstructorOptions => { // Generating tab:jump array const tabJump: MenuItemConstructorOptions[] = []; @@ -37,14 +37,14 @@ const windowMenu = ( label: 'Previous', accelerator: commandKeys['tab:prev'], click: (item, focusedWindow) => { - execCommand('tab:prev', focusedWindow); + execCommand('tab:prev', focusedWindow as BrowserWindow); } }, { label: 'Next', accelerator: commandKeys['tab:next'], click: (item, focusedWindow) => { - execCommand('tab:next', focusedWindow); + execCommand('tab:next', focusedWindow as BrowserWindow); } }, { @@ -63,14 +63,14 @@ const windowMenu = ( label: 'Previous', accelerator: commandKeys['pane:prev'], click: (item, focusedWindow) => { - execCommand('pane:prev', focusedWindow); + execCommand('pane:prev', focusedWindow as BrowserWindow); } }, { label: 'Next', accelerator: commandKeys['pane:next'], click: (item, focusedWindow) => { - execCommand('pane:next', focusedWindow); + execCommand('pane:next', focusedWindow as BrowserWindow); } } ] @@ -84,7 +84,7 @@ const windowMenu = ( { label: 'Toggle Always on Top', click: (item, focusedWindow) => { - execCommand('window:toggleKeepOnTop', focusedWindow); + execCommand('window:toggleKeepOnTop', focusedWindow as BrowserWindow); } }, { diff --git a/app/ui/contextmenu.ts b/app/ui/contextmenu.ts index 634ea882..ba5b724c 100644 --- a/app/ui/contextmenu.ts +++ b/app/ui/contextmenu.ts @@ -30,7 +30,7 @@ const contextMenuTemplate = ( const commandKeys = getCommandKeys(getDecoratedKeymaps()); const _shell = shellMenu( commandKeys, - execCommand, + (command, focusedWindow) => execCommand(command, focusedWindow as BrowserWindow | undefined), getProfiles().map((p) => p.name) ).submenu as MenuItemConstructorOptions[]; const _edit = editMenu(commandKeys, execCommand).submenu.filter(filterCutCopy.bind(null, selection));