some type fixes

This commit is contained in:
Labhansh Agrawal 2023-06-26 14:53:37 +05:30
parent b90d37bd9c
commit 0eb05e8416
4 changed files with 8 additions and 9 deletions

View file

@ -26,13 +26,12 @@ class AutoUpdater extends EventEmitter implements Electron.AutoUpdater {
this.emit('update-not-available'); this.emit('update-not-available');
return; 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. // Only name is mandatory, needed to construct release URL.
if (!name) { if (!name) {
throw new Error('Malformed server response: release name is missing.'); 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 = pub_date ? new Date(pub_date) : new Date();
const date = new Date(pub_date || null);
this.emit('update-available', {}, notes, name, date); this.emit('update-available', {}, notes, name, date);
}); });
}) })

View file

@ -58,7 +58,7 @@ if (isDev) {
console.log('running in dev mode'); console.log('running in dev mode');
// Override default appVersion which is set from package.json // 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) { if (!error) {
app.setVersion(gitInfo.raw); app.setVersion(gitInfo.raw);
} }

View file

@ -22,7 +22,7 @@ export default function fetchNotifications(win: BrowserWindow) {
}) })
.then((res) => res.json()) .then((res) => res.json())
.then((data) => { .then((data) => {
const {message} = data || {}; const message: {text: string; url: string; dismissable: boolean} | '' = data.message || '';
if (typeof message !== 'object' && message !== '') { if (typeof message !== 'object' && message !== '') {
throw new Error('Bad response'); throw new Error('Bad response');
} }

View file

@ -1,7 +1,7 @@
/* eslint-disable eslint-comments/disable-enable-pair */ /* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */ /* 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 {resolve, basename} from 'path';
import {writeFileSync} from 'fs'; import {writeFileSync} from 'fs';
import Config from 'electron-store'; import Config from 'electron-store';
@ -277,7 +277,7 @@ function requirePlugins(): any[] {
const {plugins: plugins_, localPlugins} = paths; const {plugins: plugins_, localPlugins} = paths;
const load = (path_: string) => { const load = (path_: string) => {
let mod: any; let mod: Record<string, any>;
try { try {
mod = require(path_); mod = require(path_);
const exposed = mod && Object.keys(mod).some((key) => availableExtensions.has(key)); 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') ...localPlugins.filter((p) => basename(p) !== 'migrated-hyper3-config')
] ]
.map(load) .map(load)
.filter((v) => Boolean(v)); .filter((v): v is Record<string, any> => Boolean(v));
} }
export const onApp = (app_: App) => { export const onApp = (app_: App) => {
@ -416,7 +416,7 @@ export const getDeprecatedConfig = () => {
return deprecated; return deprecated;
}; };
export const decorateMenu = (tpl: any) => { export const decorateMenu = (tpl: MenuItemConstructorOptions[]) => {
return decorateObject(tpl, 'decorateMenu'); return decorateObject(tpl, 'decorateMenu');
}; };