diff --git a/app/updater.ts b/app/updater.ts index 39ba2870..11f17d8e 100644 --- a/app/updater.ts +++ b/app/updater.ts @@ -76,21 +76,16 @@ export default (win: BrowserWindow) => { const {rpc} = win; - const onupdate = ( - ev: Event, - releaseNotes: string, - releaseName: string, - date: Date, - updateUrl: string, - onQuitAndInstall: any - ) => { + const onupdate = (ev: Event, releaseNotes: string, releaseName: string, date: Date, updateUrl: string) => { const releaseUrl = updateUrl || `https://github.com/vercel/hyper/releases/tag/${releaseName}`; - rpc.emit('update available', {releaseNotes, releaseName, releaseUrl, canInstall: !!onQuitAndInstall}); + rpc.emit('update available', {releaseNotes, releaseName, releaseUrl, canInstall: !isLinux}); }; - const eventName: any = isLinux ? 'update-available' : 'update-downloaded'; - - autoUpdater.on(eventName, onupdate); + if (isLinux) { + autoUpdater.on('update-available', onupdate); + } else { + autoUpdater.on('update-downloaded', onupdate); + } rpc.once('quit and install', () => { autoUpdater.quitAndInstall(); @@ -111,6 +106,10 @@ export default (win: BrowserWindow) => { }); win.on('close', () => { - autoUpdater.removeListener(eventName, onupdate); + if (isLinux) { + autoUpdater.removeListener('update-available', onupdate); + } else { + autoUpdater.removeListener('update-downloaded', onupdate); + } }); }; diff --git a/cli/api.ts b/cli/api.ts index cac531a3..bc1bafc4 100644 --- a/cli/api.ts +++ b/cli/api.ts @@ -30,7 +30,7 @@ const fileName = function memoize any>(fn: T): T { let hasResult = false; let result: any; - return ((...args: any[]) => { + return ((...args: Parameters) => { if (!hasResult) { result = fn(...args); hasResult = true; diff --git a/cli/index.ts b/cli/index.ts index eaa46b25..598d4220 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -191,8 +191,10 @@ const main = (argv: string[]) => { version: false, mri: { boolean: ['v', 'verbose'] - } - } as any); + }, + mainColor: 'yellow', + subColor: 'dim' + }); if (commandPromise) { return commandPromise; diff --git a/lib/actions/ui.ts b/lib/actions/ui.ts index 1005e2be..a310b682 100644 --- a/lib/actions/ui.ts +++ b/lib/actions/ui.ts @@ -31,7 +31,7 @@ import parseUrl from 'parse-url'; import {HyperState, HyperDispatch, HyperActions, ITermGroups} from '../hyper'; import {stat, Stats} from 'fs'; -export function openContextMenu(uid: string, selection: any) { +export function openContextMenu(uid: string, selection: string) { return (dispatch: HyperDispatch, getState: () => HyperState) => { dispatch({ type: UI_CONTEXTMENU_OPEN, diff --git a/lib/components/split-pane.tsx b/lib/components/split-pane.tsx index 8ca6cd8c..1ab047d5 100644 --- a/lib/components/split-pane.tsx +++ b/lib/components/split-pane.tsx @@ -24,13 +24,14 @@ export default class SplitPane extends React.PureComponent) { + const target = ev.target as HTMLDivElement; + this.panes = Array.from(target.parentElement?.children || []); + this.paneIndex = this.panes.indexOf(target); this.paneIndex -= Math.ceil(this.paneIndex / 2); } - handleAutoResize = (ev: React.MouseEvent) => { + handleAutoResize = (ev: React.MouseEvent) => { ev.preventDefault(); this.setupPanes(ev); @@ -46,8 +47,7 @@ export default class SplitPane extends React.PureComponent { - // eslint-disable-next-line @typescript-eslint/no-unsafe-call + handleDragStart = (ev: React.MouseEvent) => { ev.preventDefault(); this.setState({dragging: true}); window.addEventListener('mousemove', this.onDrag); @@ -64,10 +64,10 @@ export default class SplitPane extends React.PureComponent { dispatch(closeSearch(uid)); }, - onContextMenu(uid: string, selection: any) { + onContextMenu(uid: string, selection: string) { dispatch(setActiveSession(uid)); dispatch(openContextMenu(uid, selection)); } diff --git a/lib/reducers/ui.ts b/lib/reducers/ui.ts index a5edc7bd..19dc12a3 100644 --- a/lib/reducers/ui.ts +++ b/lib/reducers/ui.ts @@ -29,7 +29,7 @@ const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(navigator.plat const allowedCursorShapes = new Set(['BEAM', 'BLOCK', 'UNDERLINE']); const allowedCursorBlinkValues = new Set([true, false]); const allowedBells = new Set(['SOUND', 'false', false]); -const allowedHamburgerMenuValues = new Set([true, false]); +const allowedHamburgerMenuValues = new Set([true, false, '']); const allowedWindowControlsValues = new Set([true, false, 'left']); // Populate `config-default.js` from this :) @@ -239,7 +239,7 @@ const reducer: IUiReducer = (state = initial, action) => { ret.modifierKeys = config.modifierKeys; } - if (allowedHamburgerMenuValues.has(config.showHamburgerMenu as any)) { + if (allowedHamburgerMenuValues.has(config.showHamburgerMenu)) { ret.showHamburgerMenu = config.showHamburgerMenu; } diff --git a/lib/store/write-middleware.ts b/lib/store/write-middleware.ts index bd0855d5..76170a9b 100644 --- a/lib/store/write-middleware.ts +++ b/lib/store/write-middleware.ts @@ -1,10 +1,11 @@ +import {HyperActions, HyperState} from '../hyper'; import terms from '../terms'; -import {Middleware} from 'redux'; +import {Dispatch, Middleware} from 'redux'; // the only side effect we perform from middleware // is to write to the react term instance directly // to avoid a performance hit -const writeMiddleware: Middleware = () => (next) => (action) => { +const writeMiddleware: Middleware<{}, HyperState, Dispatch> = () => (next) => (action: HyperActions) => { if (action.type === 'SESSION_PTY_DATA') { const term = terms[action.uid]; if (term) { diff --git a/lib/utils/effects.ts b/lib/utils/effects.ts index 4ccdb7b1..7d5b4039 100644 --- a/lib/utils/effects.ts +++ b/lib/utils/effects.ts @@ -1,3 +1,5 @@ +import {Dispatch, Middleware} from 'redux'; +import {HyperActions, HyperState} from '../hyper'; /** * Simple redux middleware that executes * the `effect` field if provided in an action @@ -6,8 +8,7 @@ * defer or add to existing side effects at will * as the result of an action being triggered. */ -import {Middleware} from 'redux'; -const effectsMiddleware: Middleware = () => (next) => (action) => { +const effectsMiddleware: Middleware<{}, HyperState, Dispatch> = () => (next) => (action) => { const ret = next(action); if (action.effect) { // eslint-disable-next-line @typescript-eslint/no-unsafe-call diff --git a/lib/utils/plugins.ts b/lib/utils/plugins.ts index c9bc2493..5f7fecab 100644 --- a/lib/utils/plugins.ts +++ b/lib/utils/plugins.ts @@ -9,7 +9,7 @@ import {basename} from 'path'; // patching Module._load // so plugins can `require` them without needing their own version // https://github.com/vercel/hyper/issues/619 -import React, {PureComponent} from 'react'; +import React, {ComponentType, PureComponent} from 'react'; import ReactDOM from 'react-dom'; import Notification from '../components/notification'; import notify from './notify'; @@ -24,9 +24,10 @@ import { TabsProps, TermGroupOwnProps, TermProps, - Assignable + Assignable, + HyperActions } from '../hyper'; -import {Middleware} from 'redux'; +import {Dispatch, Middleware} from 'redux'; import {ObjectTypedKeys} from './object'; import IPCChildProcess from './ipc-child-process'; import ChildProcess from 'child_process'; @@ -456,10 +457,10 @@ export function getTabProps>(tab: any, parentP export function connect( stateFn: (state: HyperState) => stateProps, dispatchFn: (dispatch: HyperDispatch) => dispatchProps, - c: any, + c: null | undefined, d: Options = {} ) { - return (Class: any, name: keyof typeof connectors) => { + return (Class: ComponentType, name: keyof typeof connectors) => { return reduxConnect( (state) => { let ret = stateFn(state); @@ -570,7 +571,7 @@ export function decorateSessionsReducer(fn: ISessionReducer) { } // redux middleware generator -export const middleware: Middleware = (store) => (next) => (action) => { +export const middleware: Middleware<{}, HyperState, Dispatch> = (store) => (next) => (action) => { const nextMiddleware = (remaining: Middleware[]) => (action_: any) => remaining.length ? remaining[0](store)(nextMiddleware(remaining.slice(1)))(action_) : next(action_); nextMiddleware(middlewares)(action); diff --git a/lib/v8-snapshot-util.ts b/lib/v8-snapshot-util.ts index 4b3dd804..be6dba81 100644 --- a/lib/v8-snapshot-util.ts +++ b/lib/v8-snapshot-util.ts @@ -2,7 +2,7 @@ if (typeof snapshotResult !== 'undefined') { const Module = __non_webpack_require__('module'); const originalLoad: (module: string, ...args: any[]) => any = Module._load; - Module._load = function _load(module: string, ...args: any[]): NodeModule { + Module._load = function _load(module: string, ...args: unknown[]): NodeModule { let cachedModule = snapshotResult.customRequire.cache[module]; if (cachedModule) return cachedModule.exports;