1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

refactor: class instead of var+interface in d.ts (#7514)

This commit is contained in:
Luca Casonato 2020-09-25 16:21:34 +02:00 committed by GitHub
parent 826e899bbc
commit 3204092732
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 278 additions and 246 deletions

View file

@ -13,7 +13,12 @@
"includes": ["**/*.{ts,tsx,js,jsx,json,md}"], "includes": ["**/*.{ts,tsx,js,jsx,json,md}"],
"excludes": [ "excludes": [
".cargo_home", ".cargo_home",
"cli/dts", "cli/dts/lib.d.ts",
"cli/dts/lib.dom*",
"cli/dts/lib.es*",
"cli/dts/lib.scripthost.d.ts",
"cli/dts/lib.webworker*.d.ts",
"cli/dts/typescript.d.ts",
"cli/tests/encoding", "cli/tests/encoding",
"cli/tsc/*typescript.js", "cli/tsc/*typescript.js",
"gh-pages", "gh-pages",

View file

@ -8,128 +8,111 @@
/// <reference lib="deno.fetch" /> /// <reference lib="deno.fetch" />
declare namespace WebAssembly { declare namespace WebAssembly {
interface CompileError { export class CompileError {
} constructor();
}
var CompileError: { export class Global {
prototype: CompileError; constructor(descriptor: GlobalDescriptor, v?: any);
new(): CompileError;
};
interface Global { value: any;
value: any; valueOf(): any;
valueOf(): any; }
}
var Global: { export class Instance {
prototype: Global; constructor(module: Module, importObject?: Imports);
new(descriptor: GlobalDescriptor, v?: any): Global; readonly exports: Exports;
}; }
interface Instance { export class LinkError {
readonly exports: Exports; constructor();
} }
var Instance: { export class Memory {
prototype: Instance; constructor(descriptor: MemoryDescriptor);
new(module: Module, importObject?: Imports): Instance; readonly buffer: ArrayBuffer;
}; grow(delta: number): number;
}
interface LinkError { export class Module {
} constructor(bytes: BufferSource);
static customSections(
moduleObject: Module,
sectionName: string,
): ArrayBuffer[];
static exports(moduleObject: Module): ModuleExportDescriptor[];
static imports(moduleObject: Module): ModuleImportDescriptor[];
}
var LinkError: { export class RuntimeError {
prototype: LinkError; constructor();
new(): LinkError; }
};
interface Memory { export class Table {
readonly buffer: ArrayBuffer; constructor(descriptor: TableDescriptor);
grow(delta: number): number; readonly length: number;
} get(index: number): Function | null;
grow(delta: number): number;
set(index: number, value: Function | null): void;
}
var Memory: { export interface GlobalDescriptor {
prototype: Memory; mutable?: boolean;
new(descriptor: MemoryDescriptor): Memory; value: ValueType;
}; }
interface Module { export interface MemoryDescriptor {
} initial: number;
maximum?: number;
}
var Module: { export interface ModuleExportDescriptor {
prototype: Module; kind: ImportExportKind;
new(bytes: BufferSource): Module; name: string;
customSections(moduleObject: Module, sectionName: string): ArrayBuffer[]; }
exports(moduleObject: Module): ModuleExportDescriptor[];
imports(moduleObject: Module): ModuleImportDescriptor[];
};
interface RuntimeError { export interface ModuleImportDescriptor {
} kind: ImportExportKind;
module: string;
name: string;
}
var RuntimeError: { export interface TableDescriptor {
prototype: RuntimeError; element: TableKind;
new(): RuntimeError; initial: number;
}; maximum?: number;
}
interface Table { export interface WebAssemblyInstantiatedSource {
readonly length: number; instance: Instance;
get(index: number): Function | null; module: Module;
grow(delta: number): number; }
set(index: number, value: Function | null): void;
}
var Table: { export type ImportExportKind = "function" | "global" | "memory" | "table";
prototype: Table; export type TableKind = "anyfunc";
new(descriptor: TableDescriptor): Table; export type ValueType = "f32" | "f64" | "i32" | "i64";
}; export type ExportValue = Function | Global | Memory | Table;
export type Exports = Record<string, ExportValue>;
interface GlobalDescriptor { export type ImportValue = ExportValue | number;
mutable?: boolean; export type ModuleImports = Record<string, ImportValue>;
value: ValueType; export type Imports = Record<string, ModuleImports>;
} export function compile(bytes: BufferSource): Promise<Module>;
export function compileStreaming(
interface MemoryDescriptor { source: Response | Promise<Response>,
initial: number; ): Promise<Module>;
maximum?: number; export function instantiate(
} bytes: BufferSource,
importObject?: Imports,
interface ModuleExportDescriptor { ): Promise<WebAssemblyInstantiatedSource>;
kind: ImportExportKind; export function instantiate(
name: string; moduleObject: Module,
} importObject?: Imports,
): Promise<Instance>;
interface ModuleImportDescriptor { export function instantiateStreaming(
kind: ImportExportKind; response: Response | PromiseLike<Response>,
module: string; importObject?: Imports,
name: string; ): Promise<WebAssemblyInstantiatedSource>;
} export function validate(bytes: BufferSource): boolean;
interface TableDescriptor {
element: TableKind;
initial: number;
maximum?: number;
}
interface WebAssemblyInstantiatedSource {
instance: Instance;
module: Module;
}
type ImportExportKind = "function" | "global" | "memory" | "table";
type TableKind = "anyfunc";
type ValueType = "f32" | "f64" | "i32" | "i64";
type ExportValue = Function | Global | Memory | Table;
type Exports = Record<string, ExportValue>;
type ImportValue = ExportValue | number;
type ModuleImports = Record<string, ImportValue>;
type Imports = Record<string, ModuleImports>;
function compile(bytes: BufferSource): Promise<Module>;
function compileStreaming(source: Response | Promise<Response>): Promise<Module>;
function instantiate(bytes: BufferSource, importObject?: Imports): Promise<WebAssemblyInstantiatedSource>;
function instantiate(moduleObject: Module, importObject?: Imports): Promise<Instance>;
function instantiateStreaming(response: Response | PromiseLike<Response>, importObject?: Imports): Promise<WebAssemblyInstantiatedSource>;
function validate(bytes: BufferSource): boolean;
} }
/** Sets a timer which executes a function once after the timer expires. Returns /** Sets a timer which executes a function once after the timer expires. Returns
@ -286,35 +269,12 @@ declare interface Crypto {
): T; ): T;
} }
declare class URLSearchParams {
constructor(
init?: string[][] | Record<string, string> | string | URLSearchParams,
);
static toString(): string;
interface ResponseInit {
headers?: HeadersInit;
status?: number;
statusText?: string;
}
type ResponseType =
| "basic"
| "cors"
| "default"
| "error"
| "opaque"
| "opaqueredirect";
/** This Fetch API interface represents the response to a request. */
interface Response extends Body {
readonly headers: Headers;
readonly ok: boolean;
readonly redirected: boolean;
readonly status: number;
readonly statusText: string;
readonly trailer: Promise<Headers>;
readonly type: ResponseType;
readonly url: string;
clone(): Response;
}
interface URLSearchParams {
/** Appends a specified key/value pair as a new search parameter. /** Appends a specified key/value pair as a new search parameter.
* *
* ```ts * ```ts
@ -456,16 +416,12 @@ interface URLSearchParams {
toString(): string; toString(): string;
} }
declare const URLSearchParams: {
prototype: URLSearchParams;
new (
init?: string[][] | Record<string, string> | string | URLSearchParams,
): URLSearchParams;
toString(): string;
};
/** The URL interface represents an object providing static methods used for creating object URLs. */ /** The URL interface represents an object providing static methods used for creating object URLs. */
interface URL { declare class URL {
constructor(url: string, base?: string | URL);
createObjectURL(object: any): string;
revokeObjectURL(url: string): void;
hash: string; hash: string;
host: string; host: string;
hostname: string; hostname: string;
@ -482,13 +438,6 @@ interface URL {
toJSON(): string; toJSON(): string;
} }
declare const URL: {
prototype: URL;
new (url: string, base?: string | URL): URL;
createObjectURL(object: any): string;
revokeObjectURL(url: string): void;
};
interface MessageEventInit extends EventInit { interface MessageEventInit extends EventInit {
data?: any; data?: any;
origin?: string; origin?: string;
@ -593,7 +542,9 @@ declare class Worker extends EventTarget {
declare type PerformanceEntryList = PerformanceEntry[]; declare type PerformanceEntryList = PerformanceEntry[];
declare interface Performance { declare class Performance {
constructor();
/** Removes the stored timestamp with the associated name. */ /** Removes the stored timestamp with the associated name. */
clearMarks(markName?: string): void; clearMarks(markName?: string): void;
@ -633,11 +584,6 @@ declare interface Performance {
now(): number; now(): number;
} }
declare const Performance: {
prototype: Performance;
new (): Performance;
};
declare const performance: Performance; declare const performance: Performance;
declare interface PerformanceMarkOptions { declare interface PerformanceMarkOptions {
@ -697,19 +643,15 @@ declare class PerformanceMeasure extends PerformanceEntry {
/** Events measuring progress of an underlying process, like an HTTP request /** Events measuring progress of an underlying process, like an HTTP request
* (for an XMLHttpRequest, or the loading of the underlying resource of an * (for an XMLHttpRequest, or the loading of the underlying resource of an
* <img>, <audio>, <video>, <style> or <link>). */ * <img>, <audio>, <video>, <style> or <link>). */
interface ProgressEvent<T extends EventTarget = EventTarget> extends Event { declare class ProgressEvent<T extends EventTarget = EventTarget> extends Event {
constructor(type: string, eventInitDict?: ProgressEventInit);
readonly lengthComputable: boolean; readonly lengthComputable: boolean;
readonly loaded: number; readonly loaded: number;
readonly target: T | null; readonly target: T | null;
readonly total: number; readonly total: number;
} }
declare var ProgressEvent: { declare interface CustomEventInit<T = any> extends EventInit {
prototype: ProgressEvent;
new(type:string, eventInitDict?: ProgressEventInit): ProgressEvent;
};
interface CustomEventInit<T = any> extends EventInit {
detail?: T; detail?: T;
} }
@ -734,7 +676,8 @@ interface CloseEventInit extends EventInit {
wasClean?: boolean; wasClean?: boolean;
} }
interface CloseEvent extends Event { declare class CloseEvent extends Event {
constructor(type: string, eventInitDict?: CloseEventInit);
/** /**
* Returns the WebSocket connection close code provided by the server. * Returns the WebSocket connection close code provided by the server.
*/ */
@ -749,20 +692,22 @@ interface CloseEvent extends Event {
readonly wasClean: boolean; readonly wasClean: boolean;
} }
declare var CloseEvent: {
prototype: CloseEvent;
new(type: string, eventInitDict?: CloseEventInit): CloseEvent;
};
interface WebSocketEventMap { interface WebSocketEventMap {
"close": CloseEvent; close: CloseEvent;
"error": Event; error: Event;
"message": MessageEvent; message: MessageEvent;
"open": Event; open: Event;
} }
/** Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection. */ /** Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection. */
interface WebSocket extends EventTarget { declare class WebSocket extends EventTarget {
constructor(url: string, protocols?: string | string[]);
static readonly CLOSED: number;
static readonly CLOSING: number;
static readonly CONNECTING: number;
static readonly OPEN: number;
/** /**
* Returns a string that indicates how binary data from the WebSocket object is exposed to scripts: * Returns a string that indicates how binary data from the WebSocket object is exposed to scripts:
* *
@ -807,19 +752,26 @@ interface WebSocket extends EventTarget {
readonly CLOSING: number; readonly CLOSING: number;
readonly CONNECTING: number; readonly CONNECTING: number;
readonly OPEN: number; readonly OPEN: number;
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener<K extends keyof WebSocketEventMap>(
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; type: K,
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void; listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
removeEventListener<K extends keyof WebSocketEventMap>(
type: K,
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
} }
declare var WebSocket: {
prototype: WebSocket;
new(url: string, protocols?: string | string[]): WebSocket;
readonly CLOSED: number;
readonly CLOSING: number;
readonly CONNECTING: number;
readonly OPEN: number;
};
type BinaryType = "arraybuffer" | "blob"; type BinaryType = "arraybuffer" | "blob";

View file

@ -102,7 +102,7 @@ interface QueuingStrategy<T = any> {
} }
/** This Streams API interface provides a built-in byte length queuing strategy /** This Streams API interface provides a built-in byte length queuing strategy
* that can be used when constructing streams. */ * that can be used when constructing streams. */
declare class CountQueuingStrategy implements QueuingStrategy { declare class CountQueuingStrategy implements QueuingStrategy {
constructor(options: { highWaterMark: number }); constructor(options: { highWaterMark: number });
highWaterMark: number; highWaterMark: number;
@ -117,8 +117,8 @@ declare class ByteLengthQueuingStrategy
} }
/** This Streams API interface represents a readable stream of byte data. The /** This Streams API interface represents a readable stream of byte data. The
* Fetch API offers a concrete instance of a ReadableStream through the body * Fetch API offers a concrete instance of a ReadableStream through the body
* property of a Response object. */ * property of a Response object. */
interface ReadableStream<R = any> { interface ReadableStream<R = any> {
readonly locked: boolean; readonly locked: boolean;
cancel(reason?: any): Promise<void>; cancel(reason?: any): Promise<void>;
@ -142,7 +142,7 @@ interface ReadableStream<R = any> {
}): AsyncIterableIterator<R>; }): AsyncIterableIterator<R>;
} }
declare var ReadableStream: { declare const ReadableStream: {
prototype: ReadableStream; prototype: ReadableStream;
new ( new (
underlyingSource: UnderlyingByteSource, underlyingSource: UnderlyingByteSource,
@ -183,8 +183,8 @@ interface UnderlyingSink<W = any> {
} }
/** This Streams API interface provides a standard abstraction for writing /** This Streams API interface provides a standard abstraction for writing
* streaming data to a destination, known as a sink. This object comes with * streaming data to a destination, known as a sink. This object comes with
* built-in backpressure and queuing. */ * built-in backpressure and queuing. */
declare class WritableStream<W = any> { declare class WritableStream<W = any> {
constructor( constructor(
underlyingSink?: UnderlyingSink<W>, underlyingSink?: UnderlyingSink<W>,
@ -197,17 +197,17 @@ declare class WritableStream<W = any> {
} }
/** This Streams API interface represents a controller allowing control of a /** This Streams API interface represents a controller allowing control of a
* WritableStream's state. When constructing a WritableStream, the underlying * WritableStream's state. When constructing a WritableStream, the underlying
* sink is given a corresponding WritableStreamDefaultController instance to * sink is given a corresponding WritableStreamDefaultController instance to
* manipulate. */ * manipulate. */
interface WritableStreamDefaultController { interface WritableStreamDefaultController {
error(error?: any): void; error(error?: any): void;
} }
/** This Streams API interface is the object returned by /** This Streams API interface is the object returned by
* WritableStream.getWriter() and once created locks the < writer to the * WritableStream.getWriter() and once created locks the < writer to the
* WritableStream ensuring that no other streams can write to the underlying * WritableStream ensuring that no other streams can write to the underlying
* sink. */ * sink. */
interface WritableStreamDefaultWriter<W = any> { interface WritableStreamDefaultWriter<W = any> {
readonly closed: Promise<void>; readonly closed: Promise<void>;
readonly desiredSize: number | null; readonly desiredSize: number | null;
@ -262,7 +262,9 @@ interface BlobPropertyBag {
} }
/** A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. */ /** A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. */
interface Blob { declare class Blob {
constructor(blobParts?: BlobPart[], options?: BlobPropertyBag);
readonly size: number; readonly size: number;
readonly type: string; readonly type: string;
arrayBuffer(): Promise<ArrayBuffer>; arrayBuffer(): Promise<ArrayBuffer>;
@ -271,49 +273,50 @@ interface Blob {
text(): Promise<string>; text(): Promise<string>;
} }
declare const Blob: {
prototype: Blob;
new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
};
interface FilePropertyBag extends BlobPropertyBag { interface FilePropertyBag extends BlobPropertyBag {
lastModified?: number; lastModified?: number;
} }
/** Provides information about files and allows JavaScript in a web page to /** Provides information about files and allows JavaScript in a web page to
* access their content. */ * access their content. */
interface File extends Blob { declare class File extends Blob {
constructor(
fileBits: BlobPart[],
fileName: string,
options?: FilePropertyBag,
);
readonly lastModified: number; readonly lastModified: number;
readonly name: string; readonly name: string;
} }
declare const File: {
prototype: File;
new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File;
};
type FormDataEntryValue = File | string; type FormDataEntryValue = File | string;
/** Provides a way to easily construct a set of key/value pairs representing /** Provides a way to easily construct a set of key/value pairs representing
* form fields and their values, which can then be easily sent using the * 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 * XMLHttpRequest.send() method. It uses the same format a form would use if the
* encoding type were set to "multipart/form-data". */ * encoding type were set to "multipart/form-data". */
interface FormData extends DomIterable<string, FormDataEntryValue> { declare class FormData implements DomIterable<string, FormDataEntryValue> {
// TODO(ry) FormData constructor is non-standard.
// new(form?: HTMLFormElement): FormData;
constructor();
append(name: string, value: string | Blob, fileName?: string): void; append(name: string, value: string | Blob, fileName?: string): void;
delete(name: string): void; delete(name: string): void;
get(name: string): FormDataEntryValue | null; get(name: string): FormDataEntryValue | null;
getAll(name: string): FormDataEntryValue[]; getAll(name: string): FormDataEntryValue[];
has(name: string): boolean; has(name: string): boolean;
set(name: string, value: string | Blob, fileName?: string): void; set(name: string, value: string | Blob, fileName?: string): void;
keys(): IterableIterator<string>;
values(): IterableIterator<string>;
entries(): IterableIterator<[string, FormDataEntryValue]>;
[Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>;
forEach(
callback: (value: FormDataEntryValue, key: string, parent: this) => void,
thisArg?: any,
): void;
} }
declare const FormData: {
prototype: FormData;
// TODO(ry) FormData constructor is non-standard.
// new(form?: HTMLFormElement): FormData;
new (): FormData;
};
interface Body { interface Body {
/** A simple getter used to expose a `ReadableStream` of the body contents. */ /** A simple getter used to expose a `ReadableStream` of the body contents. */
readonly body: ReadableStream<Uint8Array> | null; readonly body: ReadableStream<Uint8Array> | null;
@ -364,7 +367,9 @@ interface Headers {
): void; ): void;
} }
interface Headers extends DomIterable<string, string> { declare class Headers implements DomIterable<string, string> {
constructor(init?: HeadersInit);
/** Appends a new value onto an existing header inside a `Headers` object, or /** Appends a new value onto an existing header inside a `Headers` object, or
* adds the header if it does not already exist. * adds the header if it does not already exist.
*/ */
@ -406,11 +411,6 @@ interface Headers extends DomIterable<string, string> {
[Symbol.iterator](): IterableIterator<[string, string]>; [Symbol.iterator](): IterableIterator<[string, string]>;
} }
declare const Headers: {
prototype: Headers;
new (init?: HeadersInit): Headers;
};
type RequestInfo = Request | string; type RequestInfo = Request | string;
type RequestCache = type RequestCache =
| "default" | "default"
@ -524,7 +524,9 @@ interface RequestInit {
} }
/** This Fetch API interface represents a resource request. */ /** This Fetch API interface represents a resource request. */
interface Request extends Body { declare class Request implements Body {
constructor(input: RequestInfo, init?: RequestInit);
/** /**
* Returns the cache mode associated with request, which is a string * Returns the cache mode associated with request, which is a string
* indicating how the request will interact with the browser's cache when * indicating how the request will interact with the browser's cache when
@ -608,28 +610,101 @@ interface Request extends Body {
*/ */
readonly url: string; readonly url: string;
clone(): Request; clone(): Request;
/** A simple getter used to expose a `ReadableStream` of the body contents. */
readonly body: ReadableStream<Uint8Array> | null;
/** Stores a `Boolean` that declares whether the body has been used in a
* response yet.
*/
readonly bodyUsed: boolean;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with an `ArrayBuffer`.
*/
arrayBuffer(): Promise<ArrayBuffer>;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with a `Blob`.
*/
blob(): Promise<Blob>;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with a `FormData` object.
*/
formData(): Promise<FormData>;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with the result of parsing the body text as JSON.
*/
json(): Promise<any>;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with a `USVString` (text).
*/
text(): Promise<string>;
} }
declare const Request: { interface ResponseInit {
prototype: Request; headers?: HeadersInit;
new (input: RequestInfo, init?: RequestInit): Request; status?: number;
}; statusText?: string;
}
declare const Response: { type ResponseType =
prototype: Response; | "basic"
new (body?: BodyInit | null, init?: ResponseInit): Response; | "cors"
error(): Response; | "default"
redirect(url: string, status?: number): Response; | "error"
}; | "opaque"
| "opaqueredirect";
/** This Fetch API interface represents the response to a request. */
declare class Response implements Body {
constructor(body?: BodyInit | null, init?: ResponseInit);
static error(): Response;
static redirect(url: string, status?: number): Response;
readonly headers: Headers;
readonly ok: boolean;
readonly redirected: boolean;
readonly status: number;
readonly statusText: string;
readonly trailer: Promise<Headers>;
readonly type: ResponseType;
readonly url: string;
clone(): Response;
/** A simple getter used to expose a `ReadableStream` of the body contents. */
readonly body: ReadableStream<Uint8Array> | null;
/** Stores a `Boolean` that declares whether the body has been used in a
* response yet.
*/
readonly bodyUsed: boolean;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with an `ArrayBuffer`.
*/
arrayBuffer(): Promise<ArrayBuffer>;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with a `Blob`.
*/
blob(): Promise<Blob>;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with a `FormData` object.
*/
formData(): Promise<FormData>;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with the result of parsing the body text as JSON.
*/
json(): Promise<any>;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with a `USVString` (text).
*/
text(): Promise<string>;
}
/** Fetch a resource from the network. It returns a Promise that resolves to the /** Fetch a resource from the network. It returns a Promise that resolves to the
* Response to that request, whether it is successful or not. * Response to that request, whether it is successful or not.
* *
* const response = await fetch("http://my.json.host/data.json"); * const response = await fetch("http://my.json.host/data.json");
* console.log(response.status); // e.g. 200 * console.log(response.status); // e.g. 200
* console.log(response.statusText); // e.g. "OK" * console.log(response.statusText); // e.g. "OK"
* const jsonData = await response.json(); * const jsonData = await response.json();
*/ */
declare function fetch( declare function fetch(
input: Request | URL | string, input: Request | URL | string,
init?: RequestInit, init?: RequestInit,