Skip to content
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

WIP: updates event target type for service workers #40881

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/lib.dom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5299,7 +5299,7 @@ interface Event {
/**
* Returns the object whose event listener's callback is currently being invoked.
*/
readonly currentTarget: EventTarget | null;
readonly currentTarget: EventTarget | ServiceWorker | null;
/**
* Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.
*/
Expand All @@ -5318,7 +5318,7 @@ interface Event {
/**
* Returns the object to which event is dispatched (its target).
*/
readonly target: EventTarget | null;
readonly target: EventTarget | ServiceWorker | null;
/**
* Returns the event's timestamp as the number of milliseconds measured relative to the time origin.
*/
Expand Down Expand Up @@ -14870,13 +14870,17 @@ interface ServiceUIFrameContext {
}
declare var ServiceUIFrameContext: ServiceUIFrameContext;

interface ServiceWorkerEvent extends Event {
readonly target: ServiceWorker;
}

interface ServiceWorkerEventMap extends AbstractWorkerEventMap {
"statechange": Event;
"statechange": ServiceWorkerEvent;
}

/** This ServiceWorker API interface provides a reference to a service worker. Multiple browsing contexts (e.g. pages, workers, etc.) can be associated with the same service worker, each through a unique ServiceWorker object. */
interface ServiceWorker extends EventTarget, AbstractWorker {
onstatechange: ((this: ServiceWorker, ev: Event) => any) | null;
onstatechange: ((this: ServiceWorker, ev: ServiceWorkerEvent) => any) | null;
readonly scriptURL: string;
readonly state: ServiceWorkerState;
postMessage(message: any, transfer: Transferable[]): void;
Expand Down