Closed
Description
TS 2.3 RC
Given:
declare const console: any;
{
(Symbol as any).asyncIterator = Symbol.asyncIterator || "__@@asyncIterator__";
const innerGen = async function* () {
yield 10
yield 20
}
const gen = async function* () {
yield* innerGen()
yield* innerGen()
}
const main = async () => {
for await (const y of gen()) {
console.log(y)
}
}
main();
}
When ran with Node, I get:
❯ tsc && node ./target/AsyncIterable.js
10
20
I expected:
10
20
10
20
When delegating to an async iterable inside, TypeScript ends the outer async iterable when the delegated async iterable ends.
This is different from the behaviour of sync iterables, and not to spec (AFAIK).