From e9e492ba8e19263e4628ac2cba65cbcd6ad255ee Mon Sep 17 00:00:00 2001 From: Kuitos Date: Fri, 26 Aug 2022 14:51:30 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=20bring=20back=20Navigator.connect?= =?UTF-8?q?ion=20type=20to=20fix=20tsc=20error=20temporary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/prefetch.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 95e3a7c..1448901 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "prettier": "^2.1.2", "rimraf": "^3.0.0", "ts-jest": "^25.2.1", - "typescript": "^4.1.2", + "typescript": "^4.8.2", "umi-plugin-hire": "^1.0.3" } } diff --git a/src/prefetch.ts b/src/prefetch.ts index f4a47f4..6af7697 100644 --- a/src/prefetch.ts +++ b/src/prefetch.ts @@ -31,6 +31,16 @@ const requestIdleCallback = }, 1); }; +declare global { + interface Navigator { + connection: { + saveData: boolean; + effectiveType: string; + type: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown'; + }; + } +} + const isSlowNetwork = navigator.connection ? navigator.connection.saveData || (navigator.connection.type !== 'wifi' &&