mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 19:08:15 +00:00
fix: declare web types as global (#12497)
Co-authored-by: Feng Yu <F3n67u@outlook.com>
This commit is contained in:
parent
8a0e206ede
commit
2997021615
3 changed files with 58 additions and 19 deletions
|
@ -122,3 +122,13 @@ unitTest(async function windowQueueMicrotask() {
|
|||
await p1;
|
||||
await p2;
|
||||
});
|
||||
|
||||
unitTest(function webApiGlobalThis() {
|
||||
assert(globalThis.FormData !== null);
|
||||
assert(globalThis.TextEncoder !== null);
|
||||
assert(globalThis.TextEncoderStream !== null);
|
||||
assert(globalThis.TextDecoder !== null);
|
||||
assert(globalThis.TextDecoderStream !== null);
|
||||
assert(globalThis.CountQueuingStrategy !== null);
|
||||
assert(globalThis.ByteLengthQueuingStrategy !== null);
|
||||
});
|
||||
|
|
11
ext/fetch/lib.deno_fetch.d.ts
vendored
11
ext/fetch/lib.deno_fetch.d.ts
vendored
|
@ -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;
|
||||
|
|
56
ext/web/lib.deno_web.d.ts
vendored
56
ext/web/lib.deno_web.d.ts
vendored
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue