[Web API type definition issue] Mark navigator.serviceWorker as an optional property
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Issue không nêu tên tệp nguồn hay bài kiểm thử nào. Hãy bắt đầu bằng cách xem lại cách generator biểu diễn Navigator và ServiceWorker, sau đó đọc issue TypeScript được liên kết và phần thảo luận hiện có trước khi thay đổi declaration. Hoàn tất khi type được tạo phản ánh hành vi tùy chọn đã được báo cáo và bước validation liên quan đạt yêu cầu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
navigator.serviceWorker may be undefined in some secure contexts, like IABs and Firefox Private Mode
Expected vs. Actual Behavior
navigator.serviceWorker.register()
Expected: throw a TypeScript error; serviceWorker may be undefined
Actual: no TypeScript error
Playground Link
No response
Browser Support
- This API is supported in at least two major browser engines (not two Chromium-based browsers).
Have Tried The Latest Releases
- This issue applies to the latest release of TypeScript.
- This issue applies to the latest release of
@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: (https://github.com/microsoft/TypeScript/issues/52044#issuecomment-1372844081)
Quoting:
APIs like these are marked non-optional for convenience, since it's extremely plausible that your script runs only in secure contexts as an invariant.
Based on his comment, it appears to me that it had been misunderstood that serviceWorker is undefined in non-secure contexts, while the point is that it may be undefined even in secure contexts.
Examples include but are not limited to:
- Firefox's private mode
- Some in-app browsers, especially those on iOS.
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 of navigator is anything but convenient.
- Ngôn ngữ chính
- TypeScript
- Star
- 740
- Fork
- 474
- Merge trung bình
- 2 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 15
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/TypeScript-DOM-lib-generator
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
microsoft/TypeScript-DOM-lib-generator#2554 · 6 bình luận ·
-
lib.d.ts bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
lib.d.ts bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
microsoft/TypeScript-DOM-lib-generator#2154 · 1 reaction ·
-
lib.d.ts bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/TypeScript-DOM-lib-generator#2107 · 5 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/TypeScript-DOM-lib-generator#1675 · 2 bình luận · 1 reaction ·
Tất cả issue của microsoft/TypeScript-DOM-lib-generator
Issue tương tự
-
Claiming namespace Londopy Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
EclipseFdn/open-vsx.org#13385 · 1 bình luận ·
-
S: triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
fix(errors): EHOSTUNREACH from a happy-eyeballs connect is reported as a resolver error (STAMP-80) Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
snapshot-labs/stamp#666 ·
-
vangogh
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
knaw-huc/textannoviz#691 ·