Asynchronous Iterations #11326
Labels
Committed
The team has roadmapped this issue
ES Next
New featurers for ECMAScript (a.k.a. ESNext)
Fixed
A PR has been merged for this issue
Suggestion
An idea for TypeScript
Milestone
The asynchronous iterations proposal is now in stage 3, so it should be safe to support that in TypeScript now. Currently, a function may be a generator or an async function, but it cannot be both. The asynchronous iteration proposal removes this restriction. Here's an example from their readme:
Types
Generator functions declare several interfaces:
Async generators return promises instead of their
IteratorResult
, and use a new symbol,Symbol.asyncIterator
:Emit
I guess that this would require another helper function to downlevel to ES2015, similar to the one used for async functions. Yield and await expression would both be replaced by yield expression, so they need to be decorated with some tag, like
yield ['await', promise]
forawait promise
.for-await-of
The proposal also introduces a new loop. An example from their readme:
This iterates over the
[Symbol.asyncIterator]()
object and awaits the value of.next()
, similar to a for-of loop. This loop can only be used in async functions.The text was updated successfully, but these errors were encountered: