🏷 upgrade typing to follow latest ts version (#1675)

This commit is contained in:
Kuitos 2021-08-29 21:18:34 +08:00 committed by GitHub
parent 9b769f224c
commit 84486daa4b

View File

@ -9,31 +9,10 @@ import { isFunction } from 'lodash';
import { getAppStatus, getMountedApps, NOT_LOADED } from 'single-spa';
import type { AppMetadata, PrefetchStrategy } from './interfaces';
type RequestIdleCallbackHandle = any;
type RequestIdleCallbackOptions = {
timeout: number;
};
type RequestIdleCallbackDeadline = {
readonly didTimeout: boolean;
timeRemaining: () => number;
};
declare global {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface Window {
requestIdleCallback: (
callback: (deadline: RequestIdleCallbackDeadline) => void,
opts?: RequestIdleCallbackOptions,
) => RequestIdleCallbackHandle;
cancelIdleCallback: (handle: RequestIdleCallbackHandle) => void;
}
interface Navigator {
connection: {
saveData: boolean;
effectiveType: string;
type: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
};
interface NetworkInformation {
saveData: boolean;
effectiveType: string;
}
}
@ -56,7 +35,7 @@ const isSlowNetwork = navigator.connection
? navigator.connection.saveData ||
(navigator.connection.type !== 'wifi' &&
navigator.connection.type !== 'ethernet' &&
/(2|3)g/.test(navigator.connection.effectiveType))
/([23])g/.test(navigator.connection.effectiveType))
: false;
/**