diff options
author | ud2 <sjx233@qq.com> | 2023-07-04 02:36:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-03 14:36:55 -0400 |
commit | d632cce129cb7025a34cf0aa7262a38fb12f47c4 (patch) | |
tree | 6fe672badbe6ea0fb8a30ecc88b74c613aaa7370 /cli/tsc/dts/lib.deno.window.d.ts | |
parent | e8a866ca8a682b552722926161a7816c5cf94124 (diff) |
fix(dts): make globals available on globalThis (#19438)
This PR changes Web IDL interfaces to be declared with `var` instead of
`class`, so that accessing them via `globalThis` does not raise type
errors.
Closes #13390.
Diffstat (limited to 'cli/tsc/dts/lib.deno.window.d.ts')
-rw-r--r-- | cli/tsc/dts/lib.deno.window.d.ts | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/cli/tsc/dts/lib.deno.window.d.ts b/cli/tsc/dts/lib.deno.window.d.ts index d0cd9b5bd..2edb2ce8f 100644 --- a/cli/tsc/dts/lib.deno.window.d.ts +++ b/cli/tsc/dts/lib.deno.window.d.ts @@ -8,14 +8,13 @@ /// <reference lib="deno.cache" /> /** @category Web APIs */ -interface WindowEventMap { +declare interface WindowEventMap { "error": ErrorEvent; "unhandledrejection": PromiseRejectionEvent; } /** @category Web APIs */ -declare class Window extends EventTarget { - new(): Window; +declare interface Window extends EventTarget { readonly window: Window & typeof globalThis; readonly self: Window & typeof globalThis; onerror: ((this: Window, ev: ErrorEvent) => any) | null; @@ -68,9 +67,19 @@ declare class Window extends EventTarget { } /** @category Web APIs */ +declare var Window: { + readonly prototype: Window; + new (): never; +}; + +/** @category Web APIs */ declare var window: Window & typeof globalThis; /** @category Web APIs */ declare var self: Window & typeof globalThis; +/** @category Web APIs */ +declare var closed: boolean; +/** @category Web APIs */ +declare function close(): void; /** @category DOM Events */ declare var onerror: ((this: Window, ev: ErrorEvent) => any) | null; /** @category DOM Events */ @@ -91,8 +100,7 @@ declare var sessionStorage: Storage; declare var caches: CacheStorage; /** @category Web APIs */ -declare class Navigator { - constructor(); +declare interface Navigator { readonly hardwareConcurrency: number; readonly userAgent: string; readonly language: string; @@ -100,6 +108,12 @@ declare class Navigator { } /** @category Web APIs */ +declare var Navigator: { + readonly prototype: Navigator; + new (): never; +}; + +/** @category Web APIs */ declare var navigator: Navigator; /** @@ -199,8 +213,7 @@ declare function removeEventListener( * * @category Web APIs */ -declare class Location { - constructor(); +declare interface Location { /** Returns a DOMStringList object listing the origins of the ancestor * browsing contexts, from the parent browsing context to the top-level * browsing context. @@ -264,5 +277,18 @@ declare class Location { // TODO(nayeemrmn): Move this to `extensions/web` where its implementation is. // The types there must first be split into window, worker and global types. +/** The location (URL) of the object it is linked to. Changes done on it are + * reflected on the object it relates to. Accessible via + * `globalThis.location`. + * + * @category Web APIs + */ +declare var Location: { + readonly prototype: Location; + new (): never; +}; + +// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is. +// The types there must first be split into window, worker and global types. /** @category Web APIs */ declare var location: Location; |