-
Notifications
You must be signed in to change notification settings - Fork 441
[Web API type definition issue] Mark navigator.serviceWorker as an optional property #1987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello @stavros-tsioulis |
Hi there @Bashamega . I am always assuming code to be running over HTTPS. However, even so, it is still not true that For example, here is the page on MDN falsely claiming that Try to open firefox on a private window and you'll find out that Contradictorily to the previous MDN page, the one for Basically: |
Hello @stavros-tsioulis |
Thanks @Bashamega |
I am not sure @stavros-tsioulis |
First of all, what is IAB? Firefox not providing Service Worker in PBM is not a feature but rather a bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1320796 Making this optional will disturb a lot of codes where the existence of service worker can be safely assumed, so this library doesn't make it optional unless the spec says so. |
Summary
navigator.serviceWorker
may beundefined
in some secure contexts, like IABs and Firefox Private ModeExpected vs. Actual Behavior
Expected: throw a TypeScript error;
serviceWorker
may beundefined
Actual: no TypeScript error
Playground Link
No response
Browser Support
Have Tried The Latest Releases
@types/web
.Additional Context
I am requesting a reconsideration of marking
navigator.serviceWorker
as optional.The previous issue opened in 2023 on the TypeScript repository has been labeled as "Working as Intended" under the explanation by Ryan Cavanaugh: (microsoft/TypeScript#52044 (comment))
Quoting:
Based on his comment, it appears to me that it had been misunderstood that
serviceWorker
isundefined
in non-secure contexts, while the point is that it may beundefined
even in secure contexts.Examples include but are not limited to:
In-app browser usage is not insignificant!
~62% of global web traffic comes from mobile devices, and, according to eMarketer, ~88% of the time people spend in their mobile devices is used on apps. Apps today incorporate IABs for the purposes of authentication, advertisement, and more. IAB usage is at its peak in social media and messaging apps.
Given the high usage of IABs.
serviceWorker
not being an optional property ofnavigator
is anything but convenient.The text was updated successfully, but these errors were encountered: