Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !5651
An error occurred while fetching the assigned milestone of the selected merge_request.

Make serviceWorker config argument optional in typescript

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/eddedd88/fix-service-worker-types into master 6 years ago
  • Overview 4
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: eddedd88

close #5650 (closed)

See issue for steps to reproduce

Compare
  • master (base)

and
  • latest version
    d125b383
    1 commit, 2 years ago

1 file
+ 3
- 3

    Preferences

    File browser
    Compare changes
packages/react-scripts/template-typescript/src/serviceWorker.ts
+ 3
- 3
  • View file @ d125b383

  • Edit in single-file editor

  • Open in Web IDE


@@ -25,7 +25,7 @@ type Config = {
@@ -25,7 +25,7 @@ type Config = {
onUpdate?: (registration: ServiceWorkerRegistration) => void;
onUpdate?: (registration: ServiceWorkerRegistration) => void;
};
};
export function register(config: Config) {
export function register(config?: Config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(
const publicUrl = new URL(
@@ -62,7 +62,7 @@ export function register(config: Config) {
@@ -62,7 +62,7 @@ export function register(config: Config) {
}
}
}
}
function registerValidSW(swUrl: string, config: Config) {
function registerValidSW(swUrl: string, config?: Config) {
navigator.serviceWorker
navigator.serviceWorker
.register(swUrl)
.register(swUrl)
.then(registration => {
.then(registration => {
@@ -106,7 +106,7 @@ function registerValidSW(swUrl: string, config: Config) {
@@ -106,7 +106,7 @@ function registerValidSW(swUrl: string, config: Config) {
});
});
}
}
function checkValidServiceWorker(swUrl: string, config: Config) {
function checkValidServiceWorker(swUrl: string, config?: Config) {
// Check if the service worker can be found. If it can't reload the page.
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
fetch(swUrl)
.then(response => {
.then(response => {
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: github/fork/eddedd88/fix-service-worker-types

Menu

Explore Projects Groups Snippets