From 0eb05e8416a1029b87742b8f1cfc923e276fe2a9 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Mon, 26 Jun 2023 14:53:37 +0530 Subject: [PATCH] some type fixes --- app/auto-updater-linux.ts | 5 ++--- app/index.ts | 2 +- app/notifications.ts | 2 +- app/plugins.ts | 8 ++++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/auto-updater-linux.ts b/app/auto-updater-linux.ts index 08bff975..4865fa4c 100644 --- a/app/auto-updater-linux.ts +++ b/app/auto-updater-linux.ts @@ -26,13 +26,12 @@ class AutoUpdater extends EventEmitter implements Electron.AutoUpdater { this.emit('update-not-available'); return; } - return res.json().then(({name, notes, pub_date}) => { + return res.json().then(({name, notes, pub_date}: {name: string; notes: string; pub_date: string}) => { // Only name is mandatory, needed to construct release URL. if (!name) { throw new Error('Malformed server response: release name is missing.'); } - // If `null` is passed to Date constructor, current time will be used. This doesn't work with `undefined` - const date = new Date(pub_date || null); + const date = pub_date ? new Date(pub_date) : new Date(); this.emit('update-available', {}, notes, name, date); }); }) diff --git a/app/index.ts b/app/index.ts index c254f93e..2b145b6d 100644 --- a/app/index.ts +++ b/app/index.ts @@ -58,7 +58,7 @@ if (isDev) { console.log('running in dev mode'); // Override default appVersion which is set from package.json - gitDescribe({customArguments: ['--tags']}, (error: any, gitInfo: any) => { + gitDescribe({customArguments: ['--tags']}, (error: any, gitInfo: {raw: string}) => { if (!error) { app.setVersion(gitInfo.raw); } diff --git a/app/notifications.ts b/app/notifications.ts index ad7aaabd..e82e5fb6 100644 --- a/app/notifications.ts +++ b/app/notifications.ts @@ -22,7 +22,7 @@ export default function fetchNotifications(win: BrowserWindow) { }) .then((res) => res.json()) .then((data) => { - const {message} = data || {}; + const message: {text: string; url: string; dismissable: boolean} | '' = data.message || ''; if (typeof message !== 'object' && message !== '') { throw new Error('Bad response'); } diff --git a/app/plugins.ts b/app/plugins.ts index 733e10c1..c5905352 100644 --- a/app/plugins.ts +++ b/app/plugins.ts @@ -1,7 +1,7 @@ /* eslint-disable eslint-comments/disable-enable-pair */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-call */ -import {app, dialog, BrowserWindow, App, ipcMain as _ipcMain} from 'electron'; +import {app, dialog, BrowserWindow, App, ipcMain as _ipcMain, MenuItemConstructorOptions} from 'electron'; import {resolve, basename} from 'path'; import {writeFileSync} from 'fs'; import Config from 'electron-store'; @@ -277,7 +277,7 @@ function requirePlugins(): any[] { const {plugins: plugins_, localPlugins} = paths; const load = (path_: string) => { - let mod: any; + let mod: Record; try { mod = require(path_); const exposed = mod && Object.keys(mod).some((key) => availableExtensions.has(key)); @@ -313,7 +313,7 @@ function requirePlugins(): any[] { ...localPlugins.filter((p) => basename(p) !== 'migrated-hyper3-config') ] .map(load) - .filter((v) => Boolean(v)); + .filter((v): v is Record => Boolean(v)); } export const onApp = (app_: App) => { @@ -416,7 +416,7 @@ export const getDeprecatedConfig = () => { return deprecated; }; -export const decorateMenu = (tpl: any) => { +export const decorateMenu = (tpl: MenuItemConstructorOptions[]) => { return decorateObject(tpl, 'decorateMenu'); };