Skip to content

Commit 9107baa

Browse files
committed
fix(cofen): fixed type errors
[bump]
1 parent 2963bed commit 9107baa

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

.changeset/few-plums-destroy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ducanh2912/next-pwa": patch
3+
---
4+
5+
fix(cofen): fixed type errors

packages/next-pwa/src/sw-entry.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Workbox } from "workbox-window";
22

33
import type { MessageType } from "./sw-entry-worker.js";
44

5-
declare const __PWA_START_URL__: URL | RequestInfo;
5+
declare const __PWA_START_URL__: string | undefined;
66
declare const __PWA_SW__: string;
77
declare const __PWA_ENABLE_REGISTER__: boolean;
88
declare const __PWA_CACHE_ON_FRONT_END_NAV__: boolean;
@@ -39,22 +39,20 @@ if (
3939
const cacheOnFrontEndNav = async (
4040
originalUrl?: string | URL | null | undefined
4141
) => {
42-
if (!window.navigator.onLine) {
42+
if (!window.navigator.onLine || !originalUrl) {
4343
return;
4444
}
4545

46-
const url = originalUrl
47-
? originalUrl instanceof URL
46+
const url =
47+
originalUrl instanceof URL
4848
? originalUrl.toString()
4949
: typeof originalUrl === "string"
5050
? originalUrl
51-
: undefined
52-
: undefined;
51+
: undefined;
5352

5453
if (typeof url !== "string") return;
5554

56-
const isStartUrl =
57-
!!__PWA_START_URL__ && originalUrl === __PWA_START_URL__;
55+
const isStartUrl = !!__PWA_START_URL__ && url === __PWA_START_URL__;
5856

5957
if (isStartUrl) {
6058
if (!swEntryWorker) {

0 commit comments

Comments
 (0)