-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
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).
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue