You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Async generator function does not flatten yielded promises #15205
I think the point of marking a function with async is so that you can write your code inside as if it was synchronous, await-ing at any points where you have to interact with asynchronous code. The transpiler machinery wraps all this appropriately so that your function obeys the async-iterator interface and returns promises from next.
I can confirm this does fix the issue, although I have a feeling the flattening should work without the await. I don't know if it's anything to go by, but this works in Babel.
Oliver Joseph Ash (@OliverJAsh) I did some digging and it looks like there was an issue filed in the proposal repo to make it behave as you are describing: tc39/proposal-async-iteration#8. This means TypeScript isn't following the spec, and should be unwrapping as you expected.
Activity
masaeedu commentedon Apr 16, 2017
Oliver Joseph Ash (@OliverJAsh) Not super familiar with this, but I think you might want to be
yield await-ing stuff insidegen. Does this work?I think the point of marking a function with async is so that you can write your code inside as if it was synchronous,
await-ing at any points where you have to interact with asynchronous code. The transpiler machinery wraps all this appropriately so that your function obeys the async-iterator interface and returns promises fromnext.OliverJAsh commentedon Apr 17, 2017
Ah, interesting.
I can confirm this does fix the issue, although I have a feeling the flattening should work without the
await. I don't know if it's anything to go by, but this works in Babel.masaeedu commentedon Apr 17, 2017
Oliver Joseph Ash (@OliverJAsh) I did some digging and it looks like there was an issue filed in the proposal repo to make it behave as you are describing: tc39/proposal-async-iteration#8. This means TypeScript isn't following the spec, and should be unwrapping as you expected.