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/web/lib.deno_web.d.ts | |
parent | 8a0e206ede0f5cc7c21312688e86a1157edb4bcf (diff) |
fix: declare web types as global (#12497)
Co-authored-by: Feng Yu <F3n67u@outlook.com>
Diffstat (limited to 'ext/web/lib.deno_web.d.ts')
-rw-r--r-- | ext/web/lib.deno_web.d.ts | 56 |
1 files changed, 42 insertions, 14 deletions
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; |