Skip to content

Conversation

@rbuckton
Copy link
Contributor

This change adds the __generator helper to tslib.js.

@rbuckton
Copy link
Contributor Author


```ts
// source:
async function func(x) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you just use a generator function instead of an async one? I think that it would simplify what exactly is going on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because we do not support down-level generators outside of async functions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exactly is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of additional complexity to fully supporting generators downlevel, specifically the following cases:

  • for..of support for generators
  • spread support for generators
  • destructuring support for generators
  • yield* support for generators
  • Symbol.iterator (or __iterator__, etc.) interop with third-party polyfill libraries.

I have written some support for these in another branch, but they are presently out of scope and are not included in the release plan.

@yuit
Copy link

yuit commented Jun 20, 2016

I follow the document and it looks good 👍 . I think it will be great if we could add __awaiter helper function (or put a link to its own section) in the Generator Object so it is clear how the Object is called and the whole thing start.

rbuckton added a commit that referenced this pull request Sep 13, 2016
@rbuckton
Copy link
Contributor Author

Closed in favor of #4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants