More ts fixes

This commit is contained in:
Philip Peterson 2025-04-21 21:11:48 -07:00
parent a9cb042bd6
commit 85e6a0d2c8
5 changed files with 20 additions and 20 deletions

View file

@ -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<string, (focusedWindow?: any) => void> = {
const commands: Record<string, (focusedWindow?: BrowserWindow) => 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);

View file

@ -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),

View file

@ -1,8 +1,8 @@
import type {BaseWindow, MenuItemConstructorOptions} from 'electron';
import type {BaseWindow, BrowserWindow, MenuItemConstructorOptions} from 'electron';
const viewMenu = (
commandKeys: Record<string, string>,
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);
}
}
]

View file

@ -1,8 +1,8 @@
import type {BaseWindow, MenuItemConstructorOptions} from 'electron';
import type {BaseWindow, BrowserWindow, MenuItemConstructorOptions} from 'electron';
const windowMenu = (
commandKeys: Record<string, string>,
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);
}
},
{

View file

@ -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));