Skip to content

Commit 6311bac

Browse files
eddedd88Timer
authored andcommitted
Make serviceWorker config argument optional in template (#5651)
1 parent e1321e5 commit 6311bac

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/react-scripts/template-typescript/src/serviceWorker.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Config = {
2525
onUpdate?: (registration: ServiceWorkerRegistration) => void;
2626
};
2727

28-
export function register(config: Config) {
28+
export function register(config?: Config) {
2929
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
3030
// The URL constructor is available in all browsers that support SW.
3131
const publicUrl = new URL(
@@ -62,7 +62,7 @@ export function register(config: Config) {
6262
}
6363
}
6464

65-
function registerValidSW(swUrl: string, config: Config) {
65+
function registerValidSW(swUrl: string, config?: Config) {
6666
navigator.serviceWorker
6767
.register(swUrl)
6868
.then(registration => {
@@ -106,7 +106,7 @@ function registerValidSW(swUrl: string, config: Config) {
106106
});
107107
}
108108

109-
function checkValidServiceWorker(swUrl: string, config: Config) {
109+
function checkValidServiceWorker(swUrl: string, config?: Config) {
110110
// Check if the service worker can be found. If it can't reload the page.
111111
fetch(swUrl)
112112
.then(response => {

0 commit comments

Comments
 (0)