feat(ext/web): add typings for `ReadableStream.from`
fixes https://github.com/denoland/deno/issues/21981
This typing implementation goes well below.
/// <reference no-default-lib="true" />
/// <reference lib="deno.web" />
function* iterable() {
yield 1;
yield 2;
yield 3;
}
const asyncIterable = (async function* () {
yield "a";
yield "b";
yield "c";
})();
const stream = ReadableStream.from(iterable());
for await (const value of stream) {
console.log(value);
}
const asyncStream = ReadableStream.from(asyncIterable);
for await (const value of asyncStream) {
console.log(value);
}
- https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/from_static
ReadableStream.from is static method. It have already defined here:
https://github.com/denoland/deno/blob/aed5e4997df26c99a186fb9a5b18da3bbc594ed3/ext/web/lib.deno_web.d.ts#L804-L818
@petamoriken
Thank you for checking, and it's my mistake.
It needs to implement typings to dom and webworker for lib option. I will fix later soon.
cli/tsc/dts/lib.webworker.d.tscli/tsc/dts/lib.dom.d.ts
from for deno.web is already defined at line 815 https://github.com/denoland/deno/blob/345423cf7697326258ce8b32f681910f4a2f77de/ext/web/lib.deno_web.d.ts#L815
#21981 is about supporting from without dom type lib
@kt3k
Thank you for suggesting.
I missed that cli/tsc/dts directory is following TypeScript repo, so it will be overwritten when its updated.
It seems to discuss that the way to provide typings.
For example, "Please use deno.web for lib compiler option" ...🤔
For example, "Please use deno.web for lib compiler option" ...🤔
BTW deno.web is enabled by default. The issue #21981 happens because deno.web is explicitly replaced by dom type lib
BTW deno.web is enabled by default.
I get it. Thank you.
It seems that a little more focus should be given to internal design or interface about this problem.👀 Thanks to all contributors!