From 84486daa4b16aba54b59a48ebb9db45f81a9d4ea Mon Sep 17 00:00:00 2001 From: Kuitos Date: Sun, 29 Aug 2021 21:18:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=20upgrade=20typing=20to=20follow?= =?UTF-8?q?=20latest=20ts=20version=20(#1675)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/prefetch.ts | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/prefetch.ts b/src/prefetch.ts index 0c4e283..f4a47f4 100644 --- a/src/prefetch.ts +++ b/src/prefetch.ts @@ -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; /**