diff --git a/cli/js/lib.deno.shared_globals.d.ts b/cli/js/lib.deno.shared_globals.d.ts
index 559fc878faf07c..2027686a90c9a3 100644
--- a/cli/js/lib.deno.shared_globals.d.ts
+++ b/cli/js/lib.deno.shared_globals.d.ts
@@ -9,16 +9,8 @@
///
///
-// https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope
-
-declare interface WindowOrWorkerGlobalScope {
- ReadableStream: __domTypes.ReadableStreamConstructor;
- location: __domTypes.Location;
-}
-
// This follows the WebIDL at: https://webassembly.github.io/spec/js-api/
// and: https://webassembly.github.io/spec/web-api/
-
declare namespace WebAssembly {
interface WebAssemblyInstantiatedSource {
module: Module;
@@ -203,8 +195,7 @@ declare function clearInterval(id?: number): void;
declare function queueMicrotask(func: Function): void;
declare const console: Console;
-declare const location: __domTypes.Location;
-declare const ReadableStream: __domTypes.ReadableStreamConstructor;
+declare const location: Location;
declare function addEventListener(
type: string,
@@ -220,188 +211,170 @@ declare function removeEventListener(
options?: boolean | EventListenerOptions | undefined
): void;
-declare type ReadableStream = __domTypes.ReadableStream;
-
declare interface ImportMeta {
url: string;
main: boolean;
}
-declare namespace __domTypes {
- export interface DomIterable {
- keys(): IterableIterator;
- values(): IterableIterator;
- entries(): IterableIterator<[K, V]>;
- [Symbol.iterator](): IterableIterator<[K, V]>;
- forEach(
- callback: (value: V, key: K, parent: this) => void,
- thisArg?: any
- ): void;
- }
- export interface ReadableStreamReadDoneResult {
- done: true;
- value?: T;
- }
- export interface ReadableStreamReadValueResult {
- done: false;
- value: T;
- }
- export type ReadableStreamReadResult =
- | ReadableStreamReadValueResult
- | ReadableStreamReadDoneResult;
- export interface ReadableStreamDefaultReader {
- readonly closed: Promise;
- cancel(reason?: any): Promise;
- read(): Promise>;
- releaseLock(): void;
- }
- export interface UnderlyingSource {
- cancel?: ReadableStreamErrorCallback;
- pull?: ReadableStreamDefaultControllerCallback;
- start?: ReadableStreamDefaultControllerCallback;
- type?: undefined;
- }
- export interface ReadableStreamErrorCallback {
- (reason: any): void | PromiseLike;
- }
+interface DomIterable {
+ keys(): IterableIterator;
+ values(): IterableIterator;
+ entries(): IterableIterator<[K, V]>;
+ [Symbol.iterator](): IterableIterator<[K, V]>;
+ forEach(
+ callback: (value: V, key: K, parent: this) => void,
+ thisArg?: any
+ ): void;
+}
- export interface ReadableStreamDefaultControllerCallback {
- (controller: ReadableStreamDefaultController): void | PromiseLike;
- }
+interface ReadableStreamReadDoneResult {
+ done: true;
+ value?: T;
+}
- export interface ReadableStreamDefaultController {
- readonly desiredSize: number;
- enqueue(chunk?: R): void;
- close(): void;
- error(e?: any): void;
- }
+interface ReadableStreamReadValueResult {
+ done: false;
+ value: T;
+}
- /** This Streams API interface represents a readable stream of byte data. The
- * Fetch API offers a concrete instance of a ReadableStream through the body
- * property of a Response object. */
- export interface ReadableStream {
- readonly locked: boolean;
- cancel(reason?: any): Promise;
- getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
- getReader(): ReadableStreamDefaultReader;
- /* disabled for now
- pipeThrough(
- {
- writable,
- readable
- }: {
- writable: WritableStream;
- readable: ReadableStream;
- },
- options?: PipeOptions
- ): ReadableStream;
- pipeTo(dest: WritableStream, options?: PipeOptions): Promise;
- */
- tee(): [ReadableStream, ReadableStream];
- }
+type ReadableStreamReadResult =
+ | ReadableStreamReadValueResult
+ | ReadableStreamReadDoneResult;
- export interface ReadableStreamConstructor {
- new (src?: UnderlyingSource): ReadableStream;
- prototype: ReadableStream;
- }
+interface ReadableStreamDefaultReader {
+ readonly closed: Promise;
+ cancel(reason?: any): Promise;
+ read(): Promise>;
+ releaseLock(): void;
+}
- export interface ReadableStreamReader {
- cancel(reason: any): Promise;
- read(): Promise>;
- releaseLock(): void;
- }
- export interface ReadableStreamBYOBReader {
- readonly closed: Promise;
- cancel(reason?: any): Promise;
- read(
- view: T
- ): Promise>;
- releaseLock(): void;
- }
- export interface WritableStream {
- readonly locked: boolean;
- abort(reason?: any): Promise;
- getWriter(): WritableStreamDefaultWriter;
- }
- export interface WritableStreamDefaultWriter {
- readonly closed: Promise;
- readonly desiredSize: number | null;
- readonly ready: Promise;
- abort(reason?: any): Promise;
- close(): Promise;
- releaseLock(): void;
- write(chunk: W): Promise;
- }
- export interface DOMStringList {
- /** Returns the number of strings in strings. */
- readonly length: number;
- /** Returns true if strings contains string, and false otherwise. */
- contains(string: string): boolean;
- /** Returns the string with index index from strings. */
- item(index: number): string | null;
- [index: number]: string;
- }
- /** The location (URL) of the object it is linked to. Changes done on it are
- * reflected on the object it relates to. Both the Document and Window
- * interface have such a linked Location, accessible via Document.location and
- * Window.location respectively. */
- export 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. */
- readonly ancestorOrigins: DOMStringList;
- /** Returns the Location object's URL's fragment (includes leading "#" if
- * non-empty).
- *
- * Can be set, to navigate to the same URL with a changed fragment (ignores
- * leading "#"). */
- hash: string;
- /** Returns the Location object's URL's host and port (if different from the
- * default port for the scheme).
- *
- * Can be set, to navigate to the same URL with a changed host and port. */
- host: string;
- /** Returns the Location object's URL's host.
- *
- * Can be set, to navigate to the same URL with a changed host. */
- hostname: string;
- /** Returns the Location object's URL.
- *
- * Can be set, to navigate to the given URL. */
- href: string;
- toString(): string;
- /** Returns the Location object's URL's origin. */
- readonly origin: string;
- /** Returns the Location object's URL's path.
- *
- * Can be set, to navigate to the same URL with a changed path. */
- pathname: string;
- /** Returns the Location object's URL's port.
- *
- * Can be set, to navigate to the same URL with a changed port. */
- port: string;
- /** Returns the Location object's URL's scheme.
- *
- * Can be set, to navigate to the same URL with a changed scheme. */
- protocol: string;
- /** Returns the Location object's URL's query (includes leading "?" if
- * non-empty).
- *
- * Can be set, to navigate to the same URL with a changed query (ignores
- * leading "?"). */
- search: string;
- /**
- * Navigates to the given URL.
- */
- assign(url: string): void;
- /**
- * Reloads the current page.
- */
- reload(): void;
- /** Removes the current page from the session history and navigates to the
- * given URL. */
- replace(url: string): void;
- }
+interface UnderlyingSource {
+ cancel?: ReadableStreamErrorCallback;
+ pull?: ReadableStreamDefaultControllerCallback;
+ start?: ReadableStreamDefaultControllerCallback;
+ type?: undefined;
+}
+
+interface ReadableStreamErrorCallback {
+ (reason: any): void | PromiseLike;
+}
+
+interface ReadableStreamDefaultControllerCallback {
+ (controller: ReadableStreamDefaultController): void | PromiseLike;
+}
+
+interface ReadableStreamDefaultController {
+ readonly desiredSize: number;
+ enqueue(chunk?: R): void;
+ close(): void;
+ error(e?: any): void;
+}
+
+/** This Streams API interface represents a readable stream of byte data. The
+ * Fetch API offers a concrete instance of a ReadableStream through the body
+ * property of a Response object. */
+interface ReadableStream {
+ readonly locked: boolean;
+ cancel(reason?: any): Promise;
+ // TODO(ry) It doesn't seem like Chrome supports this.
+ // getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
+ getReader(): ReadableStreamDefaultReader;
+ tee(): [ReadableStream, ReadableStream];
+}
+
+declare const ReadableStream: {
+ prototype: ReadableStream;
+ // TODO(ry) This doesn't match lib.dom.d.ts
+ new (src?: UnderlyingSource): ReadableStream;
+};
+
+/** This Streams API interface providesĀ a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing. */
+interface WritableStream {
+ readonly locked: boolean;
+ abort(reason?: any): Promise;
+ getWriter(): WritableStreamDefaultWriter;
+}
+
+interface WritableStreamDefaultWriter {
+ readonly closed: Promise;
+ readonly desiredSize: number | null;
+ readonly ready: Promise;
+ abort(reason?: any): Promise;
+ close(): Promise;
+ releaseLock(): void;
+ write(chunk: W): Promise;
+}
+
+interface DOMStringList {
+ /** Returns the number of strings in strings. */
+ readonly length: number;
+ /** Returns true if strings contains string, and false otherwise. */
+ contains(string: string): boolean;
+ /** Returns the string with index index from strings. */
+ item(index: number): string | null;
+ [index: number]: string;
+}
+
+/** The location (URL) of the object it is linked to. Changes done on it are
+ * reflected on the object it relates to. Both the Document and Window
+ * interface have such a linked Location, accessible via Document.location and
+ * Window.location respectively. */
+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. */
+ readonly ancestorOrigins: DOMStringList;
+ /** Returns the Location object's URL's fragment (includes leading "#" if
+ * non-empty).
+ *
+ * Can be set, to navigate to the same URL with a changed fragment (ignores
+ * leading "#"). */
+ hash: string;
+ /** Returns the Location object's URL's host and port (if different from the
+ * default port for the scheme).
+ *
+ * Can be set, to navigate to the same URL with a changed host and port. */
+ host: string;
+ /** Returns the Location object's URL's host.
+ *
+ * Can be set, to navigate to the same URL with a changed host. */
+ hostname: string;
+ /** Returns the Location object's URL.
+ *
+ * Can be set, to navigate to the given URL. */
+ href: string;
+ toString(): string;
+ /** Returns the Location object's URL's origin. */
+ readonly origin: string;
+ /** Returns the Location object's URL's path.
+ *
+ * Can be set, to navigate to the same URL with a changed path. */
+ pathname: string;
+ /** Returns the Location object's URL's port.
+ *
+ * Can be set, to navigate to the same URL with a changed port. */
+ port: string;
+ /** Returns the Location object's URL's scheme.
+ *
+ * Can be set, to navigate to the same URL with a changed scheme. */
+ protocol: string;
+ /** Returns the Location object's URL's query (includes leading "?" if
+ * non-empty).
+ *
+ * Can be set, to navigate to the same URL with a changed query (ignores
+ * leading "?"). */
+ search: string;
+ /**
+ * Navigates to the given URL.
+ */
+ assign(url: string): void;
+ /**
+ * Reloads the current page.
+ */
+ reload(): void;
+ /** Removes the current page from the session history and navigates to the
+ * given URL. */
+ replace(url: string): void;
}
type BufferSource = ArrayBufferView | ArrayBuffer;
@@ -515,7 +488,7 @@ type FormDataEntryValue = File | string;
* form fields and their values, which can then be easily sent using the
* XMLHttpRequest.send() method. It uses the same format a form would use if the
* encoding type were set to "multipart/form-data". */
-interface FormData extends __domTypes.DomIterable {
+interface FormData extends DomIterable {
append(name: string, value: string | Blob, fileName?: string): void;
delete(name: string): void;
get(name: string): FormDataEntryValue | null;
@@ -581,7 +554,7 @@ interface Headers {
): void;
}
-interface Headers extends __domTypes.DomIterable {
+interface Headers extends DomIterable {
/** Appends a new value onto an existing header inside a `Headers` object, or
* adds the header if it does not already exist.
*/
diff --git a/cli/js/lib.deno.window.d.ts b/cli/js/lib.deno.window.d.ts
index e4ab6b70dce766..2b8e6f50fc80c9 100644
--- a/cli/js/lib.deno.window.d.ts
+++ b/cli/js/lib.deno.window.d.ts
@@ -7,19 +7,20 @@
///
///
-declare interface Window extends WindowOrWorkerGlobalScope {
- window: Window & WindowOrWorkerGlobalScope & typeof globalThis;
- self: Window & WindowOrWorkerGlobalScope & typeof globalThis;
+declare interface Window {
+ window: Window & typeof globalThis;
+ self: Window & typeof globalThis;
onload: Function | undefined;
onunload: Function | undefined;
+ location: Location;
crypto: Crypto;
close: () => void;
closed: boolean;
Deno: typeof Deno;
}
-declare const window: Window & WindowOrWorkerGlobalScope & typeof globalThis;
-declare const self: Window & WindowOrWorkerGlobalScope & typeof globalThis;
+declare const window: Window & typeof globalThis;
+declare const self: Window & typeof globalThis;
declare const onload: Function | undefined;
declare const onunload: Function | undefined;
declare const crypto: Crypto;
diff --git a/cli/js/lib.deno.worker.d.ts b/cli/js/lib.deno.worker.d.ts
index 95a26924053d9f..ca3670c77457e6 100644
--- a/cli/js/lib.deno.worker.d.ts
+++ b/cli/js/lib.deno.worker.d.ts
@@ -1,15 +1,13 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-interface, @typescript-eslint/no-explicit-any */
+/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any */
///
///
///
-declare interface DedicatedWorkerGlobalScope extends WindowOrWorkerGlobalScope {
- self: DedicatedWorkerGlobalScope &
- WindowOrWorkerGlobalScope &
- typeof globalThis;
+declare interface DedicatedWorkerGlobalScope {
+ self: DedicatedWorkerGlobalScope & typeof globalThis;
onmessage: (e: { data: any }) => void;
onerror: undefined | typeof onerror;
name: typeof __workerMain.name;
@@ -17,9 +15,7 @@ declare interface DedicatedWorkerGlobalScope extends WindowOrWorkerGlobalScope {
postMessage: typeof __workerMain.postMessage;
}
-declare const self: DedicatedWorkerGlobalScope &
- WindowOrWorkerGlobalScope &
- typeof globalThis;
+declare const self: DedicatedWorkerGlobalScope & typeof globalThis;
declare let onmessage: ((e: { data: any }) => Promise | void) | undefined;
declare let onerror:
| ((
@@ -41,4 +37,4 @@ declare namespace __workerMain {
export const name: string;
}
-/* eslint-enable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-interface, @typescript-eslint/no-explicit-any */
+/* eslint-enable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any */
diff --git a/cli/tests/types.out b/cli/tests/types.out
index a212c01e8ed8d5..85bee7698ef5b8 100644
--- a/cli/tests/types.out
+++ b/cli/tests/types.out
@@ -1,16 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
[WILDCARD]
-
-declare namespace Deno {
-[WILDCARD]
-}
-[WILDCARD]
-declare interface WindowOrWorkerGlobalScope {
-[WILDCARD]
-declare interface Window extends WindowOrWorkerGlobalScope {
-[WILDCARD]
- Deno: typeof Deno;
-}
-
-declare const window: Window & WindowOrWorkerGlobalScope & typeof globalThis;
-[WILDCARD]
+declare namespace Deno [WILDCARD]
+declare const window: Window [WILDCARD]