From 84291702baa9f5d5691303f6c7d47ec5649c6333 Mon Sep 17 00:00:00 2001 From: ZaneHannanAU Date: Wed, 30 Jan 2019 13:06:29 +1100 Subject: [PATCH 1/4] webworker.d.ts: use serviceworkerglobalscope use ServiceWorkerGlobalScope in all cases --- src/webworker.d.ts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/webworker.d.ts b/src/webworker.d.ts index 88f1eae..dfc0c10 100644 --- a/src/webworker.d.ts +++ b/src/webworker.d.ts @@ -4183,7 +4183,7 @@ interface WritableStreamErrorCallback { (reason: any): void | PromiseLike; } -declare var onmessage: ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any) | null; +declare var onmessage: ((this: ServiceWorkerGlobalScope, ev: MessageEvent) => any) | null; declare function close(): void; declare function postMessage(message: any, transfer?: Transferable[]): void; /** @@ -4194,8 +4194,9 @@ declare function dispatchEvent(event: Event): boolean; declare var caches: CacheStorage; declare var isSecureContext: boolean; declare var location: WorkerLocation; -declare var onerror: ((this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any) | null; +declare var onerror: ((this: ServiceWorkerGlobalScope, ev: ErrorEvent) => any) | null; declare var performance: Performance; +declare var self: ServiceWorkerGlobalScope; declare function msWriteProfilerMark(profilerMarkName: string): void; /** * Dispatches a synthetic event event to target and returns true @@ -4225,9 +4226,25 @@ declare function fetch(input: RequestInfo, init?: RequestInit): Promise(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; +declare function addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; -declare function removeEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; +declare function removeEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; +declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +declare readonly clients: Clients; +declare var onactivate: ((this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any) | null; +declare var onfetch: ((this: ServiceWorkerGlobalScope, ev: FetchEvent) => any) | null; +declare var oninstall: ((this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any) | null; +declare var onmessageerror: ((this: ServiceWorkerGlobalScope, ev: MessageEvent) => any) | null; +declare var onnotificationclick: ((this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any) | null; +declare var onnotificationclose: ((this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any) | null; +declare var onpush: ((this: ServiceWorkerGlobalScope, ev: PushEvent) => any) | null; +declare var onpushsubscriptionchange: ((this: ServiceWorkerGlobalScope, ev: PushSubscriptionChangeEvent) => any) | null; +declare var onsync: ((this: ServiceWorkerGlobalScope, ev: SyncEvent) => any) | null; +declare readonly registration: ServiceWorkerRegistration; +declare function skipWaiting(): Promise; +declare function addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; +declare function removeEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; type BlobPart = BufferSource | Blob | string; type HeadersInit = Headers | string[][] | Record; From c252ae818fa2f02de154c212a24eeb7a91a71335 Mon Sep 17 00:00:00 2001 From: ZaneHannanAU Date: Wed, 30 Jan 2019 13:08:37 +1100 Subject: [PATCH 2/4] Update webworker.d.ts fix declarations --- src/webworker.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webworker.d.ts b/src/webworker.d.ts index dfc0c10..9768996 100644 --- a/src/webworker.d.ts +++ b/src/webworker.d.ts @@ -4230,7 +4230,7 @@ declare function addEventListener(type: K declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; declare function removeEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -declare readonly clients: Clients; +declare var clients: Clients; declare var onactivate: ((this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any) | null; declare var onfetch: ((this: ServiceWorkerGlobalScope, ev: FetchEvent) => any) | null; declare var oninstall: ((this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any) | null; @@ -4240,7 +4240,7 @@ declare var onnotificationclose: ((this: ServiceWorkerGlobalScope, ev: Notificat declare var onpush: ((this: ServiceWorkerGlobalScope, ev: PushEvent) => any) | null; declare var onpushsubscriptionchange: ((this: ServiceWorkerGlobalScope, ev: PushSubscriptionChangeEvent) => any) | null; declare var onsync: ((this: ServiceWorkerGlobalScope, ev: SyncEvent) => any) | null; -declare readonly registration: ServiceWorkerRegistration; +declare var registration: ServiceWorkerRegistration; declare function skipWaiting(): Promise; declare function addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; From 3134455f7ca62665fbca324eea9db92a3198a783 Mon Sep 17 00:00:00 2001 From: ZaneHannanAU Date: Wed, 30 Jan 2019 13:12:29 +1100 Subject: [PATCH 3/4] webworker.d.ts: remove implied parts --- src/webworker.d.ts | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/webworker.d.ts b/src/webworker.d.ts index 9768996..bf71f59 100644 --- a/src/webworker.d.ts +++ b/src/webworker.d.ts @@ -4183,7 +4183,6 @@ interface WritableStreamErrorCallback { (reason: any): void | PromiseLike; } -declare var onmessage: ((this: ServiceWorkerGlobalScope, ev: MessageEvent) => any) | null; declare function close(): void; declare function postMessage(message: any, transfer?: Transferable[]): void; /** @@ -4194,9 +4193,7 @@ declare function dispatchEvent(event: Event): boolean; declare var caches: CacheStorage; declare var isSecureContext: boolean; declare var location: WorkerLocation; -declare var onerror: ((this: ServiceWorkerGlobalScope, ev: ErrorEvent) => any) | null; declare var performance: Performance; -declare var self: ServiceWorkerGlobalScope; declare function msWriteProfilerMark(profilerMarkName: string): void; /** * Dispatches a synthetic event event to target and returns true @@ -4226,25 +4223,7 @@ declare function fetch(input: RequestInfo, init?: RequestInit): Promise(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; -declare function removeEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; -declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -declare var clients: Clients; -declare var onactivate: ((this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any) | null; -declare var onfetch: ((this: ServiceWorkerGlobalScope, ev: FetchEvent) => any) | null; -declare var oninstall: ((this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any) | null; -declare var onmessageerror: ((this: ServiceWorkerGlobalScope, ev: MessageEvent) => any) | null; -declare var onnotificationclick: ((this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any) | null; -declare var onnotificationclose: ((this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any) | null; -declare var onpush: ((this: ServiceWorkerGlobalScope, ev: PushEvent) => any) | null; -declare var onpushsubscriptionchange: ((this: ServiceWorkerGlobalScope, ev: PushSubscriptionChangeEvent) => any) | null; -declare var onsync: ((this: ServiceWorkerGlobalScope, ev: SyncEvent) => any) | null; -declare var registration: ServiceWorkerRegistration; -declare function skipWaiting(): Promise; -declare function addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; -declare function removeEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; type BlobPart = BufferSource | Blob | string; type HeadersInit = Headers | string[][] | Record; From 0a0e83e6ea27d21bbd5d6514c97b94d719d995e7 Mon Sep 17 00:00:00 2001 From: ZaneHannanAU Date: Wed, 30 Jan 2019 13:14:14 +1100 Subject: [PATCH 4/4] Include top-level functions on index ts --- index.d.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/index.d.ts b/index.d.ts index 947523c..17f26e0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,3 +4,25 @@ /// declare var self: ServiceWorkerGlobalScope; +declare var clients: Clients; +declare var registration: ServiceWorkerRegistration; + +declare var onactivate: ((this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any) | null; +declare var onerror: ((this: ServiceWorkerGlobalScope, ev: ErrorEvent) => any) | null; +declare var onfetch: ((this: ServiceWorkerGlobalScope, ev: FetchEvent) => any) | null; +declare var oninstall: ((this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any) | null; +declare var onmessageerror: ((this: ServiceWorkerGlobalScope, ev: MessageEvent) => any) | null; +declare var onmessage: ((this: ServiceWorkerGlobalScope, ev: MessageEvent) => any) | null; +declare var onnotificationclick: ((this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any) | null; +declare var onnotificationclose: ((this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any) | null; +declare var onpush: ((this: ServiceWorkerGlobalScope, ev: PushEvent) => any) | null; +declare var onpushsubscriptionchange: ((this: ServiceWorkerGlobalScope, ev: PushSubscriptionChangeEvent) => any) | null; +declare var onsync: ((this: ServiceWorkerGlobalScope, ev: SyncEvent) => any) | null; + +declare function addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; +declare function removeEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; +declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +declare function skipWaiting(): Promise; +declare function addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; +declare function removeEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void;