Closed
Description
lib Update Request
Configuration Check
My compilation target is ESNext
and my lib is the default
.
Missing / Incorrect Definition
navigator.serviceWorker
is undefined in some secure contexts (private mode on Firefox), thus the correct type definition should be:
readonly serviceWorker?: ServiceWorkerContainer;
Sample Code
Bad:
navigator.serviceWorker.register()
Good:
navigator.serviceWorker?.register()
Documentation Link
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/serviceWorker