mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(ext/web): fix typings for readable stream readers (#16191)
* Introduces `ReadableStreamDefaultReadResult` and modifies `ReadableStreamDefaultReader.read` to return this type (closes #15269). * Adds the missing `ReadableStreamBYOBReader` constructor. * Removes the nonexistent `ReadableStreamReader` class.
This commit is contained in:
parent
3f71c0dcf5
commit
972048ce36
1 changed files with 19 additions and 26 deletions
45
ext/web/lib.deno_web.d.ts
vendored
45
ext/web/lib.deno_web.d.ts
vendored
|
@ -466,30 +466,36 @@ declare class File extends Blob {
|
|||
}
|
||||
|
||||
/** @category Streams API */
|
||||
interface ReadableStreamReadDoneResult<T> {
|
||||
interface ReadableStreamDefaultReadDoneResult {
|
||||
done: true;
|
||||
value?: T;
|
||||
value?: undefined;
|
||||
}
|
||||
|
||||
/** @category Streams API */
|
||||
interface ReadableStreamReadValueResult<T> {
|
||||
interface ReadableStreamDefaultReadValueResult<T> {
|
||||
done: false;
|
||||
value: T;
|
||||
}
|
||||
|
||||
/** @category Streams API */
|
||||
type ReadableStreamReadResult<T> =
|
||||
| ReadableStreamReadValueResult<T>
|
||||
| ReadableStreamReadDoneResult<T>;
|
||||
type ReadableStreamDefaultReadResult<T> =
|
||||
| ReadableStreamDefaultReadValueResult<T>
|
||||
| ReadableStreamDefaultReadDoneResult;
|
||||
|
||||
/** @category Streams API */
|
||||
interface ReadableStreamDefaultReader<R = any> {
|
||||
readonly closed: Promise<void>;
|
||||
cancel(reason?: any): Promise<void>;
|
||||
read(): Promise<ReadableStreamReadResult<R>>;
|
||||
read(): Promise<ReadableStreamDefaultReadResult<R>>;
|
||||
releaseLock(): void;
|
||||
}
|
||||
|
||||
/** @category Streams API */
|
||||
declare var ReadableStreamDefaultReader: {
|
||||
prototype: ReadableStreamDefaultReader;
|
||||
new <R>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
|
||||
};
|
||||
|
||||
/** @category Streams API */
|
||||
interface ReadableStreamBYOBReadDoneResult<V extends ArrayBufferView> {
|
||||
done: true;
|
||||
|
@ -517,6 +523,12 @@ interface ReadableStreamBYOBReader {
|
|||
releaseLock(): void;
|
||||
}
|
||||
|
||||
/** @category Streams API */
|
||||
declare var ReadableStreamBYOBReader: {
|
||||
prototype: ReadableStreamBYOBReader;
|
||||
new (stream: ReadableStream<Uint8Array>): ReadableStreamBYOBReader;
|
||||
};
|
||||
|
||||
/** @category Streams API */
|
||||
interface ReadableStreamBYOBRequest {
|
||||
readonly view: ArrayBufferView | null;
|
||||
|
@ -524,25 +536,6 @@ interface ReadableStreamBYOBRequest {
|
|||
respondWithNewView(view: ArrayBufferView): void;
|
||||
}
|
||||
|
||||
/** @category Streams API */
|
||||
declare var ReadableStreamDefaultReader: {
|
||||
prototype: ReadableStreamDefaultReader;
|
||||
new <R>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
|
||||
};
|
||||
|
||||
/** @category Streams API */
|
||||
interface ReadableStreamReader<R = any> {
|
||||
cancel(): Promise<void>;
|
||||
read(): Promise<ReadableStreamReadResult<R>>;
|
||||
releaseLock(): void;
|
||||
}
|
||||
|
||||
/** @category Streams API */
|
||||
declare var ReadableStreamReader: {
|
||||
prototype: ReadableStreamReader;
|
||||
new (): ReadableStreamReader;
|
||||
};
|
||||
|
||||
/** @category Streams API */
|
||||
interface ReadableByteStreamControllerCallback {
|
||||
(controller: ReadableByteStreamController): void | PromiseLike<void>;
|
||||
|
|
Loading…
Reference in a new issue