summaryrefslogtreecommitdiff
path: root/cli/dts/lib.deno.window.d.ts
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2022-04-13 10:50:57 +0100
committerGitHub <noreply@github.com>2022-04-13 11:50:57 +0200
commit4d18f558e4cfebc5b8d9d594401e3ce74fc3226b (patch)
treead13a194d22b3318cf862d9ae5214143f891930a /cli/dts/lib.deno.window.d.ts
parentd621ce1cf01ea9bb5562ea3bbed7c2d1db799c91 (diff)
feat(ext/web): Add error events for event listener and timer errors (#14159)
- feat: Add handleable error event for even listener errors - feat: Add handleable error event for setTimeout()/setInterval() errors - feat: Add Deno.core.destructureError() - feat: Add Deno.core.terminate() - fix: Don't throw listener errors from dispatchEvent() - fix: Use biased mode when selecting between mod_evaluate() and run_event_loop() results
Diffstat (limited to 'cli/dts/lib.deno.window.d.ts')
-rw-r--r--cli/dts/lib.deno.window.d.ts55
1 files changed, 51 insertions, 4 deletions
diff --git a/cli/dts/lib.deno.window.d.ts b/cli/dts/lib.deno.window.d.ts
index fbd0a967b..d0e04a7a8 100644
--- a/cli/dts/lib.deno.window.d.ts
+++ b/cli/dts/lib.deno.window.d.ts
@@ -7,10 +7,15 @@
/// <reference lib="deno.webstorage" />
/// <reference lib="esnext" />
+interface WindowEventMap {
+ "error": ErrorEvent;
+}
+
declare class Window extends EventTarget {
new(): Window;
readonly window: Window & typeof globalThis;
readonly self: Window & typeof globalThis;
+ onerror: ((this: Window, ev: ErrorEvent) => any) | null;
onload: ((this: Window, ev: Event) => any) | null;
onunload: ((this: Window, ev: Event) => any) | null;
close: () => void;
@@ -25,10 +30,38 @@ declare class Window extends EventTarget {
location: Location;
localStorage: Storage;
sessionStorage: Storage;
+
+ addEventListener<K extends keyof WindowEventMap>(
+ type: K,
+ listener: (
+ this: Window,
+ ev: WindowEventMap[K],
+ ) => any,
+ options?: boolean | AddEventListenerOptions,
+ ): void;
+ addEventListener(
+ type: string,
+ listener: EventListenerOrEventListenerObject,
+ options?: boolean | AddEventListenerOptions,
+ ): void;
+ removeEventListener<K extends keyof WindowEventMap>(
+ type: K,
+ listener: (
+ this: Window,
+ ev: WindowEventMap[K],
+ ) => any,
+ options?: boolean | EventListenerOptions,
+ ): void;
+ removeEventListener(
+ type: string,
+ listener: EventListenerOrEventListenerObject,
+ options?: boolean | EventListenerOptions,
+ ): void;
}
declare var window: Window & typeof globalThis;
declare var self: Window & typeof globalThis;
+declare var onerror: ((this: Window, ev: ErrorEvent) => any) | null;
declare var onload: ((this: Window, ev: Event) => any) | null;
declare var onunload: ((this: Window, ev: Event) => any) | null;
declare var localStorage: Storage;
@@ -77,10 +110,17 @@ declare function prompt(message?: string, defaultValue?: string): string | null;
* dispatchEvent(new Event('unload'));
* ```
*/
+declare function addEventListener<
+ K extends keyof WindowEventMap,
+>(
+ type: K,
+ listener: (this: Window, ev: WindowEventMap[K]) => any,
+ options?: boolean | AddEventListenerOptions,
+): void;
declare function addEventListener(
type: string,
- callback: EventListenerOrEventListenerObject | null,
- options?: boolean | AddEventListenerOptions | undefined,
+ listener: EventListenerOrEventListenerObject,
+ options?: boolean | AddEventListenerOptions,
): void;
/** Remove a previously registered event listener from the global scope
@@ -91,10 +131,17 @@ declare function addEventListener(
* removeEventListener('load', listener);
* ```
*/
+declare function removeEventListener<
+ K extends keyof WindowEventMap,
+>(
+ type: K,
+ listener: (this: Window, ev: WindowEventMap[K]) => any,
+ options?: boolean | EventListenerOptions,
+): void;
declare function removeEventListener(
type: string,
- callback: EventListenerOrEventListenerObject | null,
- options?: boolean | EventListenerOptions | undefined,
+ listener: EventListenerOrEventListenerObject,
+ options?: boolean | EventListenerOptions,
): void;
// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is.