-
Couldn't load subscription status.
- Fork 181
Description
What is the issue with the Web IDL Standard?
For background, see the discussion here: https://gist.github.com/MattiasBuelens/496fc1d37adb50a733edd43853f2f60e
In short, I noticed while trying to drop a spec-compliant polyfill for ReadableStream's async iteration into Typescript that the types weren't matching up with AsyncIterator. The return method for async generators can accept a promise, rather than a plain value, which is awaited and unwrapped into the return value like so: {done: true, value: resultOfAwaitedPromise}. Whereas, the async iterator corresponding to the webidl spec seems to not do this, instead returning {done: true, value: unawaitedPromise}.
To illustrate the discrepancy:
let gen = (async function*() {})();
await gen.return(Promise.resolve('foo'));
// -> { done: true, value: 'foo' }
let gen = new ReadableStream().values();
await gen.return(Promise.resolve('foo'));
// -> { done: true, value: Promise {<fulfilled>: 'foo'} }So I am curious if this is an oversight somewhere or intentional for some reason?