diff --git a/cli/tsc/dts/lib.dom.d.ts b/cli/tsc/dts/lib.dom.d.ts index 0a2f9b9edaa6e0..2684735597a37a 100644 --- a/cli/tsc/dts/lib.dom.d.ts +++ b/cli/tsc/dts/lib.dom.d.ts @@ -18277,7 +18277,7 @@ declare var ReadableStream: { new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number }): ReadableStream; new(underlyingSource: UnderlyingDefaultSource, strategy?: QueuingStrategy): ReadableStream; new(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream; - from(asyncIterable: AsyncIterable | Iterable>): ReadableStream; + from(asyncIterable: AsyncIterable | Iterable> & object): ReadableStream; }; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */ diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index f29e5f204009be..57a437e4f5c304 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -2922,7 +2922,7 @@ function readableStreamPipeTo( } /** - * @param {ReadableStreamGenericReader | ReadableStreamBYOBReader} reader + * @param {ReadableStreamGenericReader | ReadableStreamBYOBReader} reader * @param {any} reason * @returns {Promise} */ @@ -2955,7 +2955,7 @@ function readableStreamReaderGenericInitialize(reader, stream) { /** * @template R - * @param {ReadableStreamGenericReader | ReadableStreamBYOBReader} reader + * @param {ReadableStreamGenericReader | ReadableStreamBYOBReader} reader */ function readableStreamReaderGenericRelease(reader) { const stream = reader[_stream]; diff --git a/ext/web/06_streams_types.d.ts b/ext/web/06_streams_types.d.ts index e04f568d26644a..fe05ee6e65b167 100644 --- a/ext/web/06_streams_types.d.ts +++ b/ext/web/06_streams_types.d.ts @@ -60,8 +60,8 @@ interface VoidFunction { (): void; } -interface ReadableStreamGenericReader { - readonly closed: Promise; +interface ReadableStreamGenericReader { + readonly closed: Promise; // deno-lint-ignore no-explicit-any cancel(reason?: any): Promise; } diff --git a/ext/web/lib.deno_web.d.ts b/ext/web/lib.deno_web.d.ts index 2ad97ac7d1eef2..8aafbad535923a 100644 --- a/ext/web/lib.deno_web.d.ts +++ b/ext/web/lib.deno_web.d.ts @@ -882,7 +882,7 @@ declare var ReadableStream: { strategy?: QueuingStrategy, ): ReadableStream; from( - asyncIterable: AsyncIterable | Iterable>, + asyncIterable: AsyncIterable | Iterable> & object, ): ReadableStream; }; diff --git a/tests/specs/check/reject_string_in_readable_stream_from/__test__.jsonc b/tests/specs/check/reject_string_in_readable_stream_from/__test__.jsonc new file mode 100644 index 00000000000000..634dbac8503ab5 --- /dev/null +++ b/tests/specs/check/reject_string_in_readable_stream_from/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "check ./main.ts", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/specs/check/reject_string_in_readable_stream_from/main.out b/tests/specs/check/reject_string_in_readable_stream_from/main.out new file mode 100644 index 00000000000000..577c1fb059df7f --- /dev/null +++ b/tests/specs/check/reject_string_in_readable_stream_from/main.out @@ -0,0 +1,5 @@ +Check [WILDCARD]/main.ts +error: TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'AsyncIterable | (Iterable> & object)'. +ReadableStream.from("string"); + ~~~~~~~~ + at [WILDCARD]/main.ts:1:21 diff --git a/tests/specs/check/reject_string_in_readable_stream_from/main.ts b/tests/specs/check/reject_string_in_readable_stream_from/main.ts new file mode 100644 index 00000000000000..5e7fc9c9563ec5 --- /dev/null +++ b/tests/specs/check/reject_string_in_readable_stream_from/main.ts @@ -0,0 +1 @@ +ReadableStream.from("string"); diff --git a/tests/unit/streams_test.ts b/tests/unit/streams_test.ts index 73f9a60953c84b..53225a1553c6a3 100644 --- a/tests/unit/streams_test.ts +++ b/tests/unit/streams_test.ts @@ -541,6 +541,7 @@ Deno.test(async function decompressionStreamInvalidGzipStillReported() { Deno.test(function readableStreamFromWithStringThrows() { assertThrows( + // @ts-expect-error: primitives are not acceptable () => ReadableStream.from("string"), TypeError, "Failed to execute 'ReadableStream.from': Argument 1 can not be converted to async iterable.",