diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-10-21 08:47:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-21 08:47:14 +0200 |
commit | 299702161533d731db799f1bb6c7c95fd92c0c11 (patch) | |
tree | b390c1b114a852eea04bc53dc252885f0bd6fb35 /ext | |
parent | 8a0e206ede0f5cc7c21312688e86a1157edb4bcf (diff) |
fix: declare web types as global (#12497)
Co-authored-by: Feng Yu <F3n67u@outlook.com>
Diffstat (limited to 'ext')
-rw-r--r-- | ext/fetch/lib.deno_fetch.d.ts | 11 | ||||
-rw-r--r-- | ext/web/lib.deno_web.d.ts | 56 |
2 files changed, 48 insertions, 19 deletions
diff --git a/ext/fetch/lib.deno_fetch.d.ts b/ext/fetch/lib.deno_fetch.d.ts index 7fe7d9453..e2f693d28 100644 --- a/ext/fetch/lib.deno_fetch.d.ts +++ b/ext/fetch/lib.deno_fetch.d.ts @@ -22,11 +22,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". */ -declare class FormData implements DomIterable<string, FormDataEntryValue> { - // TODO(ry) FormData constructor is non-standard. - // new(form?: HTMLFormElement): FormData; - constructor(); - +interface FormData { append(name: string, value: string | Blob, fileName?: string): void; delete(name: string): void; get(name: string): FormDataEntryValue | null; @@ -43,6 +39,11 @@ declare class FormData implements DomIterable<string, FormDataEntryValue> { ): void; } +declare var FormData: { + prototype: FormData; + new (): FormData; +}; + interface Body { /** A simple getter used to expose a `ReadableStream` of the body contents. */ readonly body: ReadableStream<Uint8Array> | null; diff --git a/ext/web/lib.deno_web.d.ts b/ext/web/lib.deno_web.d.ts index 7733c7a4f..108bfb7b3 100644 --- a/ext/web/lib.deno_web.d.ts +++ b/ext/web/lib.deno_web.d.ts @@ -186,26 +186,29 @@ declare interface TextDecodeOptions { stream?: boolean; } -declare class TextDecoder { - constructor(label?: string, options?: TextDecoderOptions); - +interface TextDecoder { /** Returns encoding's name, lowercased. */ readonly encoding: string; /** Returns `true` if error mode is "fatal", and `false` otherwise. */ readonly fatal: boolean; /** Returns `true` if ignore BOM flag is set, and `false` otherwise. */ - readonly ignoreBOM = false; + readonly ignoreBOM: boolean; /** Returns the result of running encoding's decoder. */ decode(input?: BufferSource, options?: TextDecodeOptions): string; } +declare var TextDecoder: { + prototype: TextDecoder; + new (label?: string, options?: TextDecoderOptions): TextDecoder; +}; + declare interface TextEncoderEncodeIntoResult { read: number; written: number; } -declare class TextEncoder { +interface TextEncoder { /** Returns "utf-8". */ readonly encoding: "utf-8"; /** Returns the result of running UTF-8's encoder. */ @@ -213,20 +216,29 @@ declare class TextEncoder { encodeInto(input: string, dest: Uint8Array): TextEncoderEncodeIntoResult; } -declare class TextDecoderStream { +declare var TextEncoder: { + prototype: TextEncoder; + new (): TextEncoder; +}; + +interface TextDecoderStream { /** Returns encoding's name, lowercased. */ readonly encoding: string; /** Returns `true` if error mode is "fatal", and `false` otherwise. */ readonly fatal: boolean; /** Returns `true` if ignore BOM flag is set, and `false` otherwise. */ - readonly ignoreBOM = false; - constructor(label?: string, options?: TextDecoderOptions); + readonly ignoreBOM: boolean; readonly readable: ReadableStream<string>; readonly writable: WritableStream<BufferSource>; readonly [Symbol.toStringTag]: string; } -declare class TextEncoderStream { +declare var TextDecoderStream: { + prototype: TextDecoderStream; + new (label?: string, options?: TextDecoderOptions): TextDecoderStream; +}; + +interface TextEncoderStream { /** Returns "utf-8". */ readonly encoding: "utf-8"; readonly readable: ReadableStream<Uint8Array>; @@ -234,6 +246,11 @@ declare class TextEncoderStream { readonly [Symbol.toStringTag]: string; } +declare var TextEncoderStream: { + prototype: TextEncoderStream; + new (): TextEncoderStream; +}; + /** A controller object that allows you to abort one or more DOM requests as and * when desired. */ declare class AbortController { @@ -493,19 +510,26 @@ interface QueuingStrategy<T = any> { /** This Streams API interface provides a built-in byte length queuing strategy * that can be used when constructing streams. */ -declare class CountQueuingStrategy implements QueuingStrategy { - constructor(options: { highWaterMark: number }); +interface CountQueuingStrategy extends QueuingStrategy { highWaterMark: number; size(chunk: any): 1; } -declare class ByteLengthQueuingStrategy - implements QueuingStrategy<ArrayBufferView> { - constructor(options: { highWaterMark: number }); +declare var CountQueuingStrategy: { + prototype: CountQueuingStrategy; + new (options: { highWaterMark: number }): CountQueuingStrategy; +}; + +interface ByteLengthQueuingStrategy extends QueuingStrategy<ArrayBufferView> { highWaterMark: number; size(chunk: ArrayBufferView): number; } +declare var ByteLengthQueuingStrategy: { + prototype: ByteLengthQueuingStrategy; + new (options: { highWaterMark: number }): ByteLengthQueuingStrategy; +}; + /** 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. */ @@ -590,6 +614,8 @@ interface WritableStreamDefaultController { error(error?: any): void; } +declare var WritableStreamDefaultController: WritableStreamDefaultController; + /** This Streams API interface is the object returned by * WritableStream.getWriter() and once created locks the < writer to the * WritableStream ensuring that no other streams can write to the underlying @@ -630,6 +656,8 @@ interface TransformStreamDefaultController<O = any> { terminate(): void; } +declare var TransformStreamDefaultController: TransformStreamDefaultController; + interface Transformer<I = any, O = any> { flush?: TransformStreamDefaultControllerCallback<O>; readableType?: undefined; |