From d8ad9ef066e112551ac0e2de5af4029becf91e2a Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Fri, 20 Dec 2019 23:25:03 +0530 Subject: [PATCH] port app/menus to ts --- app/menus/menus/{darwin.js => darwin.ts} | 10 +++++++--- app/menus/menus/{edit.js => edit.ts} | 11 ++++++++--- app/menus/menus/{help.js => help.ts} | 6 +++--- app/menus/menus/{plugins.js => plugins.ts} | 7 ++++++- app/menus/menus/{shell.js => shell.ts} | 7 ++++++- app/menus/menus/{view.js => view.ts} | 7 ++++++- app/menus/menus/{window.js => window.ts} | 7 ++++++- 7 files changed, 42 insertions(+), 13 deletions(-) rename app/menus/menus/{darwin.js => darwin.ts} (74%) rename app/menus/menus/{edit.js => edit.ts} (92%) rename app/menus/menus/{help.js => help.ts} (91%) rename app/menus/menus/{plugins.js => plugins.ts} (63%) rename app/menus/menus/{shell.js => shell.ts} (85%) rename app/menus/menus/{view.js => view.ts} (84%) rename app/menus/menus/{window.js => window.ts} (89%) diff --git a/app/menus/menus/darwin.js b/app/menus/menus/darwin.ts similarity index 74% rename from app/menus/menus/darwin.js rename to app/menus/menus/darwin.ts index 9e50b771..6756ab20 100644 --- a/app/menus/menus/darwin.js +++ b/app/menus/menus/darwin.ts @@ -1,8 +1,12 @@ // This menu label is overrided by OSX to be the appName // The label is set to appName here so it matches actual behavior -import {app} from 'electron'; +import {app, BrowserWindow, MenuItemConstructorOptions} from 'electron'; -export default (commandKeys, execCommand, showAbout) => { +export default ( + commandKeys: Record, + execCommand: (command: string, focusedWindow?: BrowserWindow) => void, + showAbout: () => void +): MenuItemConstructorOptions => { return { label: `${app.getName()}`, submenu: [ @@ -36,7 +40,7 @@ export default (commandKeys, execCommand, showAbout) => { role: 'hide' }, { - role: 'hideothers' + role: 'hideOthers' }, { role: 'unhide' diff --git a/app/menus/menus/edit.js b/app/menus/menus/edit.ts similarity index 92% rename from app/menus/menus/edit.js rename to app/menus/menus/edit.ts index 67aba6e6..40387b51 100644 --- a/app/menus/menus/edit.js +++ b/app/menus/menus/edit.ts @@ -1,5 +1,10 @@ -export default (commandKeys, execCommand) => { - const submenu = [ +import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; + +export default ( + commandKeys: Record, + execCommand: (command: string, focusedWindow?: BrowserWindow) => void +) => { + const submenu: MenuItemConstructorOptions[] = [ { label: 'Undo', accelerator: commandKeys['editor:undo'], @@ -23,7 +28,7 @@ export default (commandKeys, execCommand) => { command: 'editor:copy', accelerator: commandKeys['editor:copy'], registerAccelerator: true - }, + } as any, { role: 'paste', accelerator: commandKeys['editor:paste'] diff --git a/app/menus/menus/help.js b/app/menus/menus/help.ts similarity index 91% rename from app/menus/menus/help.js rename to app/menus/menus/help.ts index c9ac4985..07d4414b 100644 --- a/app/menus/menus/help.js +++ b/app/menus/menus/help.ts @@ -1,11 +1,11 @@ import {release} from 'os'; -import {app, shell} from 'electron'; +import {app, shell, MenuItemConstructorOptions} from 'electron'; import {getConfig, getPlugins} from '../../config'; const {arch, env, platform, versions} = process; import {version} from '../../package.json'; -export default (commands, showAbout) => { - const submenu = [ +export default (commands: Record, showAbout: () => void): MenuItemConstructorOptions => { + const submenu: MenuItemConstructorOptions[] = [ { label: `${app.getName()} Website`, click() { diff --git a/app/menus/menus/plugins.js b/app/menus/menus/plugins.ts similarity index 63% rename from app/menus/menus/plugins.js rename to app/menus/menus/plugins.ts index 2ca8702e..47a6a6c2 100644 --- a/app/menus/menus/plugins.js +++ b/app/menus/menus/plugins.ts @@ -1,4 +1,9 @@ -export default (commands, execCommand) => { +import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; + +export default ( + commands: Record, + execCommand: (command: string, focusedWindow?: BrowserWindow) => void +): MenuItemConstructorOptions => { return { label: 'Plugins', submenu: [ diff --git a/app/menus/menus/shell.js b/app/menus/menus/shell.ts similarity index 85% rename from app/menus/menus/shell.js rename to app/menus/menus/shell.ts index 958f53f2..ec8bde39 100644 --- a/app/menus/menus/shell.js +++ b/app/menus/menus/shell.ts @@ -1,4 +1,9 @@ -export default (commandKeys, execCommand) => { +import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; + +export default ( + commandKeys: Record, + execCommand: (command: string, focusedWindow?: BrowserWindow) => void +): MenuItemConstructorOptions => { const isMac = process.platform === 'darwin'; return { diff --git a/app/menus/menus/view.js b/app/menus/menus/view.ts similarity index 84% rename from app/menus/menus/view.js rename to app/menus/menus/view.ts index ff89e445..98f9ef1e 100644 --- a/app/menus/menus/view.js +++ b/app/menus/menus/view.ts @@ -1,4 +1,9 @@ -export default (commandKeys, execCommand) => { +import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; + +export default ( + commandKeys: Record, + execCommand: (command: string, focusedWindow?: BrowserWindow) => void +): MenuItemConstructorOptions => { return { label: 'View', submenu: [ diff --git a/app/menus/menus/window.js b/app/menus/menus/window.ts similarity index 89% rename from app/menus/menus/window.js rename to app/menus/menus/window.ts index 4f9fb4cd..8ea018dc 100644 --- a/app/menus/menus/window.js +++ b/app/menus/menus/window.ts @@ -1,4 +1,9 @@ -export default (commandKeys, execCommand) => { +import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; + +export default ( + commandKeys: Record, + execCommand: (command: string, focusedWindow?: BrowserWindow) => void +): MenuItemConstructorOptions => { // Generating tab:jump array const tabJump = []; for (let i = 1; i <= 9; i++) {