Skip to content

ServiceWorkerRegistration.Update() should return Promise<ServiceWorkerRegistration> #31502

Open
@ahardin13

Description

@ahardin13

TypeScript Version: 3.4.3

Search Terms:
ServiceWorkerRegistration Update

Code

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
let isUpdating: boolean;
navigator.serviceWorker.getRegistration().then(sw => {
    sw.update().then(result => {
        if (result.installing || result.waiting) {
            isUpdating = true;
        }
    });
});

Expected behavior:
result is of type ServiceWorkerRegistration and result.installing and result.waiting are valid.
https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/update

Actual behavior:
result is of type void and tsc gives errors
error TS2339: Property 'installing' does not exist on type 'void'.
error TS2339: Property 'waiting' does not exist on type 'void'.

Playground Link

Related Issues:
#17590

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions