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

fix(types): Conform lib.deno_web.d.ts to lib.dom.d.ts and lib.webworker.d.ts (#24599)

Fix #24578
Fix #21981
This commit is contained in:
Kenta Moriuchi 2024-07-23 05:02:39 +09:00 committed by GitHub
parent 6960637b5c
commit 715675565a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 387 additions and 173 deletions

View file

@ -1930,11 +1930,16 @@ interface TrackEventInit extends EventInit {
track?: TextTrack | null;
}
interface TransformerCancelCallback {
(reason: any): void | PromiseLike<void>;
}
interface Transformer<I = any, O = any> {
flush?: TransformerFlushCallback<O>;
readableType?: undefined;
start?: TransformerStartCallback<O>;
transform?: TransformerTransformCallback<I, O>;
cancel?: TransformerCancelCallback;
writableType?: undefined;
}
@ -5847,6 +5852,8 @@ declare var CompositionEvent: {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream) */
interface CompressionStream extends GenericTransformStream {
readonly readable: ReadableStream<Uint8Array>;
readonly writable: WritableStream<BufferSource>;
}
declare var CompressionStream: {
@ -6744,6 +6751,8 @@ declare var DataTransferItemList: {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream) */
interface DecompressionStream extends GenericTransformStream {
readonly readable: ReadableStream<Uint8Array>;
readonly writable: WritableStream<BufferSource>;
}
declare var DecompressionStream: {
@ -8873,9 +8882,7 @@ declare var GamepadHapticActuator: {
};
interface GenericTransformStream {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream/readable) */
readonly readable: ReadableStream;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream/writable) */
readonly writable: WritableStream;
}
@ -18816,22 +18823,27 @@ interface ReadableStream<R = any> {
declare var ReadableStream: {
prototype: ReadableStream;
new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number }): ReadableStream<Uint8Array>;
new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number; size?: undefined }): ReadableStream<Uint8Array>;
new<R = any>(underlyingSource: UnderlyingDefaultSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
new<R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
from<R>(asyncIterable: AsyncIterable<R> | Iterable<R | PromiseLike<R>>): ReadableStream<R>;
};
interface ReadableStreamBYOBReaderReadOptions {
min?: number;
}
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */
interface ReadableStreamBYOBReader extends ReadableStreamGenericReader {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */
read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
read<T extends ArrayBufferView>(view: T, options?: ReadableStreamBYOBReaderReadOptions): Promise<ReadableStreamReadResult<T>>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */
releaseLock(): void;
}
declare var ReadableStreamBYOBReader: {
prototype: ReadableStreamBYOBReader;
new(stream: ReadableStream): ReadableStreamBYOBReader;
new(stream: ReadableStream<Uint8Array>): ReadableStreamBYOBReader;
};
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) */

View file

@ -717,11 +717,16 @@ interface TextEncoderEncodeIntoResult {
written: number;
}
interface TransformerCancelCallback {
(reason: any): void | PromiseLike<void>;
}
interface Transformer<I = any, O = any> {
flush?: TransformerFlushCallback<O>;
readableType?: undefined;
start?: TransformerStartCallback<O>;
transform?: TransformerTransformCallback<I, O>;
cancel?: TransformerCancelCallback;
writableType?: undefined;
}
@ -1807,6 +1812,8 @@ declare var CloseEvent: {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream) */
interface CompressionStream extends GenericTransformStream {
readonly readable: ReadableStream<Uint8Array>;
readonly writable: WritableStream<BufferSource>;
}
declare var CompressionStream: {
@ -2258,6 +2265,8 @@ declare var DOMStringList: {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream) */
interface DecompressionStream extends GenericTransformStream {
readonly readable: ReadableStream<Uint8Array>;
readonly writable: WritableStream<BufferSource>;
}
declare var DecompressionStream: {
@ -3082,9 +3091,7 @@ declare var FormData: {
};
interface GenericTransformStream {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream/readable) */
readonly readable: ReadableStream;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream/writable) */
readonly writable: WritableStream;
}
@ -4875,22 +4882,27 @@ interface ReadableStream<R = any> {
declare var ReadableStream: {
prototype: ReadableStream;
new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number }): ReadableStream<Uint8Array>;
new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number; size?: undefined }): ReadableStream<Uint8Array>;
new<R = any>(underlyingSource: UnderlyingDefaultSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
new<R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
from<R>(asyncIterable: AsyncIterable<R> | Iterable<R | PromiseLike<R>>): ReadableStream<R>;
};
interface ReadableStreamBYOBReaderReadOptions {
min?: number;
}
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */
interface ReadableStreamBYOBReader extends ReadableStreamGenericReader {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */
read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
read<T extends ArrayBufferView>(view: T, options?: ReadableStreamBYOBReaderReadOptions): Promise<ReadableStreamReadResult<T>>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */
releaseLock(): void;
}
declare var ReadableStreamBYOBReader: {
prototype: ReadableStreamBYOBReader;
new(stream: ReadableStream): ReadableStreamBYOBReader;
new(stream: ReadableStream<Uint8Array>): ReadableStreamBYOBReader;
};
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) */

View file

@ -9,6 +9,7 @@
declare interface DOMException extends Error {
readonly name: string;
readonly message: string;
/** @deprecated */
readonly code: number;
readonly INDEX_SIZE_ERR: 1;
readonly DOMSTRING_SIZE_ERR: 2;
@ -84,6 +85,7 @@ declare interface Event {
* event goes through its target's ancestors in reverse tree order, and
* false otherwise. */
readonly bubbles: boolean;
/** @deprecated */
cancelBubble: boolean;
/** Returns true or false depending on how event was initialized. Its return
* value does not always carry meaning, but true can indicate that part of the
@ -106,6 +108,10 @@ declare interface Event {
/** Returns true if event was dispatched by the user agent, and false
* otherwise. */
readonly isTrusted: boolean;
/** @deprecated */
returnValue: boolean;
/** @deprecated */
readonly srcElement: EventTarget | null;
/** Returns the object to which event is dispatched (its target). */
readonly target: EventTarget | null;
/** Returns the event's timestamp as the number of milliseconds measured
@ -118,6 +124,8 @@ declare interface Event {
* the shadow root's mode is "closed" that are not reachable from event's
* currentTarget. */
composedPath(): EventTarget[];
/** @deprecated */
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
/** If invoked when the cancelable attribute value is true, and while
* executing a listener for the event with passive set to false, signals to
* the operation that caused event to be dispatched that it needs to be
@ -130,10 +138,10 @@ declare interface Event {
/** When dispatched in a tree, invoking this method prevents event from
* reaching any objects other than the current object. */
stopPropagation(): void;
readonly AT_TARGET: number;
readonly BUBBLING_PHASE: number;
readonly CAPTURING_PHASE: number;
readonly NONE: number;
readonly NONE: 0;
readonly CAPTURING_PHASE: 1;
readonly AT_TARGET: 2;
readonly BUBBLING_PHASE: 3;
}
/** An event which takes place in the DOM.
@ -143,10 +151,10 @@ declare interface Event {
declare var Event: {
readonly prototype: Event;
new (type: string, eventInitDict?: EventInit): Event;
readonly AT_TARGET: number;
readonly BUBBLING_PHASE: number;
readonly CAPTURING_PHASE: number;
readonly NONE: number;
readonly NONE: 0;
readonly CAPTURING_PHASE: 1;
readonly AT_TARGET: 2;
readonly BUBBLING_PHASE: 3;
};
/**
@ -210,12 +218,12 @@ declare var EventTarget: {
/** @category Events */
declare interface EventListener {
(evt: Event): void | Promise<void>;
(evt: Event): void;
}
/** @category Events */
declare interface EventListenerObject {
handleEvent(evt: Event): void | Promise<void>;
handleEvent(evt: Event): void;
}
/** @category Events */
@ -299,14 +307,7 @@ declare interface TextDecodeOptions {
}
/** @category Encoding */
declare 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: boolean;
declare interface TextDecoder extends TextDecoderCommon {
/** Returns the result of running encoding's decoder. */
decode(input?: BufferSource, options?: TextDecodeOptions): string;
}
@ -317,6 +318,16 @@ declare var TextDecoder: {
new (label?: string, options?: TextDecoderOptions): TextDecoder;
};
/** @category Encoding */
declare interface TextDecoderCommon {
/** Returns encoding's name, lowercased. */
readonly encoding: string;
/** Returns true if error mode is "fatal", otherwise false. */
readonly fatal: boolean;
/** Returns the value of ignore BOM. */
readonly ignoreBOM: boolean;
}
/** @category Encoding */
declare interface TextEncoderEncodeIntoResult {
read: number;
@ -324,9 +335,7 @@ declare interface TextEncoderEncodeIntoResult {
}
/** @category Encoding */
declare interface TextEncoder {
/** Returns "utf-8". */
readonly encoding: "utf-8";
declare interface TextEncoder extends TextEncoderCommon {
/** Returns the result of running UTF-8's encoder. */
encode(input?: string): Uint8Array;
encodeInto(input: string, dest: Uint8Array): TextEncoderEncodeIntoResult;
@ -339,16 +348,16 @@ declare var TextEncoder: {
};
/** @category Encoding */
declare interface TextDecoderStream {
/** Returns encoding's name, lowercased. */
declare interface TextEncoderCommon {
/** Returns "utf-8". */
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: boolean;
}
/** @category Encoding */
declare interface TextDecoderStream
extends GenericTransformStream, TextDecoderCommon {
readonly readable: ReadableStream<string>;
readonly writable: WritableStream<BufferSource>;
readonly [Symbol.toStringTag]: string;
}
/** @category Encoding */
@ -358,12 +367,10 @@ declare var TextDecoderStream: {
};
/** @category Encoding */
declare interface TextEncoderStream {
/** Returns "utf-8". */
readonly encoding: "utf-8";
declare interface TextEncoderStream
extends GenericTransformStream, TextEncoderCommon {
readonly readable: ReadableStream<Uint8Array>;
readonly writable: WritableStream<string>;
readonly [Symbol.toStringTag]: string;
}
/** @category Encoding */
@ -472,16 +479,20 @@ declare interface FileReader extends EventTarget {
| ((this: FileReader, ev: ProgressEvent<FileReader>) => any)
| null;
onprogress: ((this: FileReader, ev: ProgressEvent<FileReader>) => any) | null;
readonly readyState: number;
readonly readyState:
| typeof FileReader.EMPTY
| typeof FileReader.LOADING
| typeof FileReader.DONE;
readonly result: string | ArrayBuffer | null;
abort(): void;
readAsArrayBuffer(blob: Blob): void;
/** @deprecated */
readAsBinaryString(blob: Blob): void;
readAsDataURL(blob: Blob): void;
readAsText(blob: Blob, encoding?: string): void;
readonly DONE: number;
readonly EMPTY: number;
readonly LOADING: number;
readonly EMPTY: 0;
readonly LOADING: 1;
readonly DONE: 2;
addEventListener<K extends keyof FileReaderEventMap>(
type: K,
listener: (this: FileReader, ev: FileReaderEventMap[K]) => any,
@ -508,18 +519,21 @@ declare interface FileReader extends EventTarget {
declare var FileReader: {
readonly prototype: FileReader;
new (): FileReader;
readonly DONE: number;
readonly EMPTY: number;
readonly LOADING: number;
readonly EMPTY: 0;
readonly LOADING: 1;
readonly DONE: 2;
};
/** @category File */
declare type BlobPart = BufferSource | Blob | string;
/** @category File */
declare type EndingType = "transparent" | "native";
/** @category File */
declare interface BlobPropertyBag {
type?: string;
endings?: "transparent" | "native";
endings?: EndingType;
}
/** A file-like object of immutable, raw data. Blobs represent data that isn't
@ -564,6 +578,7 @@ declare interface FilePropertyBag extends BlobPropertyBag {
declare interface File extends Blob {
readonly lastModified: number;
readonly name: string;
readonly webkitRelativePath: string;
}
/** Provides information about files and allows JavaScript in a web page to
@ -577,66 +592,62 @@ declare var File: {
};
/** @category Streams */
declare interface ReadableStreamDefaultReadDoneResult {
done: true;
value?: undefined;
declare type ReadableStreamReader<T> =
| ReadableStreamDefaultReader<T>
| ReadableStreamBYOBReader;
/** @category Streams */
declare type ReadableStreamController<T> =
| ReadableStreamDefaultController<T>
| ReadableByteStreamController;
/** @category Streams */
declare interface ReadableStreamGenericReader {
readonly closed: Promise<undefined>;
cancel(reason?: any): Promise<void>;
}
/** @category Streams */
declare interface ReadableStreamDefaultReadValueResult<T> {
declare interface ReadableStreamReadDoneResult<T> {
done: true;
value?: T;
}
/** @category Streams */
declare interface ReadableStreamReadValueResult<T> {
done: false;
value: T;
}
/** @category Streams */
declare type ReadableStreamDefaultReadResult<T> =
| ReadableStreamDefaultReadValueResult<T>
| ReadableStreamDefaultReadDoneResult;
declare type ReadableStreamReadResult<T> =
| ReadableStreamReadValueResult<T>
| ReadableStreamReadDoneResult<T>;
/** @category Streams */
declare interface ReadableStreamDefaultReader<R = any> {
readonly closed: Promise<void>;
cancel(reason?: any): Promise<void>;
read(): Promise<ReadableStreamDefaultReadResult<R>>;
declare interface ReadableStreamDefaultReader<R = any>
extends ReadableStreamGenericReader {
read(): Promise<ReadableStreamReadResult<R>>;
releaseLock(): void;
}
/** @category Streams */
declare var ReadableStreamDefaultReader: {
readonly prototype: ReadableStreamDefaultReader;
new <R>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
new <R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
};
/** @category Streams */
declare interface ReadableStreamBYOBReadDoneResult<V extends ArrayBufferView> {
done: true;
value?: V;
}
/** @category Streams */
declare interface ReadableStreamBYOBReadValueResult<V extends ArrayBufferView> {
done: false;
value: V;
}
/** @category Streams */
declare type ReadableStreamBYOBReadResult<V extends ArrayBufferView> =
| ReadableStreamBYOBReadDoneResult<V>
| ReadableStreamBYOBReadValueResult<V>;
/** @category Streams */
declare interface ReadableStreamBYOBReaderReadOptions {
min?: number;
}
/** @category Streams */
declare interface ReadableStreamBYOBReader {
readonly closed: Promise<void>;
cancel(reason?: any): Promise<void>;
read<V extends ArrayBufferView>(
view: V,
declare interface ReadableStreamBYOBReader extends ReadableStreamGenericReader {
read<T extends ArrayBufferView>(
view: T,
options?: ReadableStreamBYOBReaderReadOptions,
): Promise<ReadableStreamBYOBReadResult<V>>;
): Promise<ReadableStreamReadResult<T>>;
releaseLock(): void;
}
@ -659,7 +670,11 @@ declare var ReadableStreamBYOBRequest: {
new (): never;
};
/** @category Streams */
// TODO(petamoriken): Will be removed in v2.0.
/**
* @deprecated use `UnderlyingByteSource["pull"]` instead.
* @category Streams
*/
declare interface ReadableByteStreamControllerCallback {
(controller: ReadableByteStreamController): void | PromiseLike<void>;
}
@ -667,45 +682,79 @@ declare interface ReadableByteStreamControllerCallback {
/** @category Streams */
declare interface UnderlyingByteSource {
autoAllocateChunkSize?: number;
cancel?: ReadableStreamErrorCallback;
pull?: ReadableByteStreamControllerCallback;
start?: ReadableByteStreamControllerCallback;
cancel?: UnderlyingSourceCancelCallback;
pull?: (controller: ReadableByteStreamController) => void | PromiseLike<void>;
start?: (controller: ReadableByteStreamController) => any;
type: "bytes";
}
/** @category Streams */
declare interface UnderlyingSink<W = any> {
abort?: WritableStreamErrorCallback;
close?: WritableStreamDefaultControllerCloseCallback;
start?: WritableStreamDefaultControllerStartCallback;
declare interface UnderlyingDefaultSource<R = any> {
cancel?: UnderlyingSourceCancelCallback;
pull?: (
controller: ReadableStreamDefaultController<R>,
) => void | PromiseLike<void>;
start?: (controller: ReadableStreamDefaultController<R>) => any;
type?: undefined;
write?: WritableStreamDefaultControllerWriteCallback<W>;
}
/** @category Streams */
declare interface UnderlyingSink<W = any> {
abort?: UnderlyingSinkAbortCallback;
close?: UnderlyingSinkCloseCallback;
start?: UnderlyingSinkStartCallback;
type?: undefined;
write?: UnderlyingSinkWriteCallback<W>;
}
/** @category Streams */
declare type ReadableStreamType = "bytes";
/** @category Streams */
declare interface UnderlyingSource<R = any> {
cancel?: ReadableStreamErrorCallback;
pull?: ReadableStreamDefaultControllerCallback<R>;
start?: ReadableStreamDefaultControllerCallback<R>;
type?: undefined;
autoAllocateChunkSize?: number;
cancel?: UnderlyingSourceCancelCallback;
pull?: UnderlyingSourcePullCallback<R>;
start?: UnderlyingSourceStartCallback<R>;
type?: ReadableStreamType;
}
// TODO(petamoriken): Will be removed in v2.0.
/**
* @deprecated use `UnderlyingSourceCancelCallback` instead.
* @category Streams
*/
declare type ReadableStreamErrorCallback = UnderlyingSourceCancelCallback;
/** @category Streams */
declare interface UnderlyingSourceCancelCallback {
(reason?: any): void | PromiseLike<void>;
}
// TODO(petamoriken): Will be removed in v2.0.
/**
* @deprecated use `UnderlyingSourcePullCallback` instead.
* @category Streams
*/
declare type ReadableStreamDefaultControllerCallback<R> =
UnderlyingSourcePullCallback<R>;
/** @category Streams */
declare interface UnderlyingSourcePullCallback<R> {
(controller: ReadableStreamController<R>): void | PromiseLike<void>;
}
/** @category Streams */
declare interface ReadableStreamErrorCallback {
(reason: any): void | PromiseLike<void>;
}
/** @category Streams */
declare interface ReadableStreamDefaultControllerCallback<R> {
(controller: ReadableStreamDefaultController<R>): void | PromiseLike<void>;
declare interface UnderlyingSourceStartCallback<R> {
(controller: ReadableStreamController<R>): any;
}
/** @category Streams */
declare interface ReadableStreamDefaultController<R = any> {
readonly desiredSize: number | null;
close(): void;
enqueue(chunk: R): void;
error(error?: any): void;
enqueue(chunk?: R): void;
error(e?: any): void;
}
/** @category Streams */
@ -720,7 +769,7 @@ declare interface ReadableByteStreamController {
readonly desiredSize: number | null;
close(): void;
enqueue(chunk: ArrayBufferView): void;
error(error?: any): void;
error(e?: any): void;
}
/** @category Streams */
@ -729,23 +778,37 @@ declare var ReadableByteStreamController: {
new (): never;
};
// TODO(petamoriken): Will be removed in v2.0.
/**
* @deprecated use `StreamPipeOptions` instead.
* @category Streams
*/
declare type PipeOptions = StreamPipeOptions;
/** @category Streams */
declare interface PipeOptions {
declare interface StreamPipeOptions {
preventAbort?: boolean;
preventCancel?: boolean;
preventClose?: boolean;
signal?: AbortSignal;
}
// TODO(petamoriken): Will be removed in v2.0.
/**
* @deprecated use `QueuingStrategySize` instead.
* @category Streams
*/
declare type QueuingStrategySizeCallback<T = any> = QueuingStrategySize<T>;
/** @category Streams */
declare interface QueuingStrategySizeCallback<T = any> {
declare interface QueuingStrategySize<T = any> {
(chunk: T): number;
}
/** @category Streams */
declare interface QueuingStrategy<T = any> {
highWaterMark?: number;
size?: QueuingStrategySizeCallback<T>;
size?: QueuingStrategySize<T>;
}
/** This Streams API interface provides a built-in byte length queuing strategy
@ -754,29 +817,34 @@ declare interface QueuingStrategy<T = any> {
* @category Streams
*/
declare interface CountQueuingStrategy extends QueuingStrategy {
highWaterMark: number;
size(chunk: any): 1;
readonly highWaterMark: number;
readonly size: QueuingStrategySize;
}
/** @category Streams */
declare var CountQueuingStrategy: {
readonly prototype: CountQueuingStrategy;
new (options: { highWaterMark: number }): CountQueuingStrategy;
new (init: QueuingStrategyInit): CountQueuingStrategy;
};
/** @category Streams */
declare interface ByteLengthQueuingStrategy
extends QueuingStrategy<ArrayBufferView> {
highWaterMark: number;
size(chunk: ArrayBufferView): number;
readonly highWaterMark: number;
readonly size: QueuingStrategySize<ArrayBufferView>;
}
/** @category Streams */
declare var ByteLengthQueuingStrategy: {
readonly prototype: ByteLengthQueuingStrategy;
new (options: { highWaterMark: number }): ByteLengthQueuingStrategy;
new (init: QueuingStrategyInit): ByteLengthQueuingStrategy;
};
/** @category Streams */
declare interface QueuingStrategyInit {
highWaterMark: number;
}
/** 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.
@ -787,19 +855,21 @@ declare interface ReadableStream<R = any> {
readonly locked: boolean;
cancel(reason?: any): Promise<void>;
getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
getReader(options?: { mode?: undefined }): ReadableStreamDefaultReader<R>;
pipeThrough<T>(transform: {
writable: WritableStream<R>;
readable: ReadableStream<T>;
}, options?: PipeOptions): ReadableStream<T>;
pipeTo(dest: WritableStream<R>, options?: PipeOptions): Promise<void>;
getReader(): ReadableStreamDefaultReader<R>;
getReader(options?: ReadableStreamGetReaderOptions): ReadableStreamReader<R>;
pipeThrough<T>(
transform: ReadableWritablePair<T, R>,
options?: StreamPipeOptions,
): ReadableStream<T>;
pipeTo(
destination: WritableStream<R>,
options?: StreamPipeOptions,
): Promise<void>;
tee(): [ReadableStream<R>, ReadableStream<R>];
values(options?: {
preventCancel?: boolean;
}): AsyncIterableIterator<R>;
[Symbol.asyncIterator](options?: {
preventCancel?: boolean;
}): AsyncIterableIterator<R>;
values(options?: ReadableStreamIteratorOptions): AsyncIterableIterator<R>;
[Symbol.asyncIterator](
options?: ReadableStreamIteratorOptions,
): AsyncIterableIterator<R>;
}
/** @category Streams */
@ -809,6 +879,10 @@ declare var ReadableStream: {
underlyingSource: UnderlyingByteSource,
strategy?: { highWaterMark?: number; size?: undefined },
): ReadableStream<Uint8Array>;
new <R = any>(
underlyingSource: UnderlyingDefaultSource<R>,
strategy?: QueuingStrategy<R>,
): ReadableStream<R>;
new <R = any>(
underlyingSource?: UnderlyingSource<R>,
strategy?: QueuingStrategy<R>,
@ -819,27 +893,76 @@ declare var ReadableStream: {
};
/** @category Streams */
declare interface WritableStreamDefaultControllerCloseCallback {
declare interface ReadableStreamIteratorOptions {
preventCancel?: boolean;
}
/** @category Streams */
declare type ReadableStreamReaderMode = "byob";
/** @category Streams */
declare interface ReadableStreamGetReaderOptions {
mode?: ReadableStreamReaderMode;
}
/** @category Streams */
declare interface ReadableWritablePair<R = any, W = any> {
readable: ReadableStream<R>;
writable: WritableStream<W>;
}
// TODO(petamoriken): Will be removed in v2.0.
/**
* @deprecated use `UnderlyingSinkCloseCallback` instead.
* @category Streams
*/
declare type WritableStreamDefaultControllerCloseCallback =
UnderlyingSinkCloseCallback;
/** @category Streams */
declare interface UnderlyingSinkCloseCallback {
(): void | PromiseLike<void>;
}
/** @category Streams */
declare interface WritableStreamDefaultControllerStartCallback {
(controller: WritableStreamDefaultController): void | PromiseLike<void>;
}
// TODO(petamoriken): Will be removed in v2.0.
/**
* @deprecated use `UnderlyingSinkStartCallback` instead.
* @category Streams
*/
declare type WritableStreamDefaultControllerStartCallback =
UnderlyingSinkStartCallback;
/** @category Streams */
declare interface WritableStreamDefaultControllerWriteCallback<W> {
(chunk: W, controller: WritableStreamDefaultController):
| void
| PromiseLike<
void
>;
declare interface UnderlyingSinkStartCallback {
(controller: WritableStreamDefaultController): any;
}
// TODO(petamoriken): Will be removed in v2.0.
/**
* @deprecated use `UnderlyingSinkWriteCallback` instead.
* @category Streams
*/
declare type WritableStreamDefaultControllerWriteCallback<W> =
UnderlyingSinkWriteCallback<W>;
/** @category Streams */
declare interface WritableStreamErrorCallback {
(reason: any): void | PromiseLike<void>;
declare interface UnderlyingSinkWriteCallback<W> {
(
chunk: W,
controller: WritableStreamDefaultController,
): void | PromiseLike<void>;
}
// TODO(petamoriken): Will be removed in v2.0.
/**
* @deprecated use `UnderlyingSinkAbortCallback` instead.
* @category Streams
*/
declare type WritableStreamErrorCallback = UnderlyingSinkAbortCallback;
/** @category Streams */
declare interface UnderlyingSinkAbortCallback {
(reason?: any): void | PromiseLike<void>;
}
/** This Streams API interface provides a standard abstraction for writing
@ -872,8 +995,8 @@ declare var WritableStream: {
* @category Streams
*/
declare interface WritableStreamDefaultController {
signal: AbortSignal;
error(error?: any): void;
readonly signal: AbortSignal;
error(e?: any): void;
}
/** @category Streams */
@ -890,19 +1013,19 @@ declare var WritableStreamDefaultController: {
* @category Streams
*/
declare interface WritableStreamDefaultWriter<W = any> {
readonly closed: Promise<void>;
readonly closed: Promise<undefined>;
readonly desiredSize: number | null;
readonly ready: Promise<void>;
readonly ready: Promise<undefined>;
abort(reason?: any): Promise<void>;
close(): Promise<void>;
releaseLock(): void;
write(chunk: W): Promise<void>;
write(chunk?: W): Promise<void>;
}
/** @category Streams */
declare var WritableStreamDefaultWriter: {
readonly prototype: WritableStreamDefaultWriter;
new <W>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>;
new <W = any>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>;
};
/** @category Streams */
@ -924,7 +1047,7 @@ declare var TransformStream: {
/** @category Streams */
declare interface TransformStreamDefaultController<O = any> {
readonly desiredSize: number | null;
enqueue(chunk: O): void;
enqueue(chunk?: O): void;
error(reason?: any): void;
terminate(): void;
}
@ -937,32 +1060,69 @@ declare var TransformStreamDefaultController: {
/** @category Streams */
declare interface Transformer<I = any, O = any> {
flush?: TransformStreamDefaultControllerCallback<O>;
flush?: TransformerFlushCallback<O>;
readableType?: undefined;
start?: TransformStreamDefaultControllerCallback<O>;
transform?: TransformStreamDefaultControllerTransformCallback<I, O>;
cancel?: (reason: any) => Promise<void>;
start?: TransformerStartCallback<O>;
transform?: TransformerTransformCallback<I, O>;
cancel?: TransformerCancelCallback;
writableType?: undefined;
}
// TODO(petamoriken): Will be removed in v2.0.
/**
* @deprecated use `TransformerFlushCallback` instead.
* @category Streams
*/
declare type TransformStreamDefaultControllerCallback<O> =
TransformerFlushCallback<O>;
/** @category Streams */
declare interface TransformStreamDefaultControllerCallback<O> {
declare interface TransformerFlushCallback<O> {
(controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
}
/** @category Streams */
declare interface TransformStreamDefaultControllerTransformCallback<I, O> {
declare interface TransformerStartCallback<O> {
(controller: TransformStreamDefaultController<O>): any;
}
// TODO(petamoriken): Will be removed in v2.0.
/**
* @deprecated use `TransformerTransformCallback` instead.
* @category Streams
*/
declare type TransformStreamDefaultControllerTransformCallback<I, O> =
TransformerTransformCallback<I, O>;
/** @category Streams */
declare interface TransformerTransformCallback<I, O> {
(
chunk: I,
controller: TransformStreamDefaultController<O>,
): void | PromiseLike<void>;
}
/** @category Streams */
declare interface TransformerCancelCallback {
(reason: any): void | PromiseLike<void>;
}
/** @category Streams */
declare interface GenericTransformStream {
readonly readable: ReadableStream;
readonly writable: WritableStream;
}
/** @category Events */
declare type MessageEventSource = Window | MessagePort;
/** @category Events */
declare interface MessageEventInit<T = any> extends EventInit {
data?: T;
origin?: string;
lastEventId?: string;
origin?: string;
ports?: MessagePort[];
source?: MessageEventSource | null;
}
/** @category Events */
@ -979,11 +1139,22 @@ declare interface MessageEvent<T = any> extends Event {
* Returns the last event ID string, for server-sent events.
*/
readonly lastEventId: string;
readonly source: null;
readonly source: MessageEventSource | null;
/**
* Returns transferred ports.
*/
readonly ports: ReadonlyArray<MessagePort>;
/** @deprecated */
initMessageEvent(
type: string,
bubbles?: boolean,
cancelable?: boolean,
data?: any,
origin?: string,
lastEventId?: string,
source?: MessageEventSource | null,
ports?: MessagePort[],
): void;
}
/** @category Events */
@ -993,12 +1164,10 @@ declare var MessageEvent: {
};
/** @category Events */
declare type Transferable = ArrayBuffer | MessagePort;
declare type Transferable = MessagePort | ArrayBuffer;
// TODO(petamoriken): Will be removed in v2.0.
/**
* This type has been renamed to StructuredSerializeOptions. Use that type for
* new code.
*
* @deprecated use `StructuredSerializeOptions` instead.
* @category Events
*/
@ -1142,11 +1311,14 @@ declare function structuredClone<T = any>(
*
* @category Streams
*/
declare interface CompressionStream {
declare interface CompressionStream extends GenericTransformStream {
readonly readable: ReadableStream<Uint8Array>;
readonly writable: WritableStream<Uint8Array>;
readonly writable: WritableStream<BufferSource>;
}
/** @category Streams */
declare type CompressionFormat = "deflate" | "deflate-raw" | "gzip";
/**
* An API for compressing a stream of data.
*
@ -1168,7 +1340,7 @@ declare var CompressionStream: {
* Throws a `TypeError` if the format passed to the constructor is not
* supported.
*/
new (format: string): CompressionStream;
new (format: CompressionFormat): CompressionStream;
};
/**
@ -1186,9 +1358,9 @@ declare var CompressionStream: {
*
* @category Streams
*/
declare interface DecompressionStream {
declare interface DecompressionStream extends GenericTransformStream {
readonly readable: ReadableStream<Uint8Array>;
readonly writable: WritableStream<Uint8Array>;
readonly writable: WritableStream<BufferSource>;
}
/**
@ -1215,7 +1387,7 @@ declare var DecompressionStream: {
* Throws a `TypeError` if the format passed to the constructor is not
* supported.
*/
new (format: string): DecompressionStream;
new (format: CompressionFormat): DecompressionStream;
};
/** Dispatch an uncaught exception. Similar to a synchronous version of:
@ -1257,7 +1429,7 @@ declare interface ImageData {
/** @category Platform */
declare var ImageData: {
prototype: ImageData;
readonly prototype: ImageData;
new (sw: number, sh: number, settings?: ImageDataSettings): ImageData;
new (
data: Uint8ClampedArray,

View file

@ -1,4 +1,4 @@
{
"args": "run --check dom_extras_dts.ts",
"output": "dom_extras_dts.out"
"args": "run --check main.ts",
"output": "main.out"
}

View file

@ -1,3 +0,0 @@
Check [WILDCARD]dom_extras_dts.ts
URLPattern[WILDCARD]
function

View file

@ -0,0 +1,3 @@
Check [WILDCARD]main.ts
URLPattern[WILDCARD]
function

View file

@ -0,0 +1,4 @@
{
"args": "run --check main.ts",
"output": "main.out"
}

View file

@ -0,0 +1,8 @@
{
"compilerOptions": {
"lib": [
"deno.ns",
"dom"
]
}
}

View file

@ -0,0 +1,2 @@
Check [WILDCARD]main.ts
ReadableStream[WILDCARD]

View file

@ -0,0 +1,4 @@
const asyncIterable = (async function* () {
yield* [1, 2, 3];
})();
console.log(ReadableStream.from(asyncIterable));