Skip to content

Commit

Permalink
[flow] Add types for ServiceWorker show notification api
Browse files Browse the repository at this point in the history
Summary:
I'm trying to improve the types used in our service worker infra and this is a missing type not defined anywhere.

So adding it here.

Spec:

https://notifications.spec.whatwg.org/#service-worker-api

Changelog: [libdef] Add libdef types for `getNotifications` and `showNotification` API for `ServiceWorkerRegistration`

Reviewed By: SamChou19815

Differential Revision: D66535415

fbshipit-source-id: b83b3514218230c9b7bc21744c352fd70f99a6f4
  • Loading branch information
yashsriv authored and facebook-github-bot committed Dec 5, 2024
1 parent c5356e6 commit 3204c02
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/serviceworkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ declare class PushManager {

type ServiceWorkerUpdateViaCache = 'imports' | 'all' | 'none';

type GetNotificationOptions = {
tag?: string,
...
};

declare class ServiceWorkerRegistration extends EventTarget {
+installing: ?ServiceWorker,
+waiting: ?ServiceWorker,
Expand All @@ -141,6 +146,8 @@ declare class ServiceWorkerRegistration extends EventTarget {
+updateViaCache: ServiceWorkerUpdateViaCache,
+pushManager: PushManager,

getNotifications?: (filter?: GetNotificationOptions) => Promise<$ReadOnlyArray<Notification>>,
showNotification?: (title: string, options?: NotificationOptions) => Promise<void>,
update(): Promise<void>,
unregister(): Promise<boolean>,

Expand Down

0 comments on commit 3204c02

Please sign in to comment.