Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator helper #2

Closed
wants to merge 7 commits into from
Closed

Generator helper #2

wants to merge 7 commits into from

Conversation

rbuckton
Copy link
Member

This change adds the __generator helper to tslib.js.

@rbuckton
Copy link
Member 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
Member 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
Member 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
Member 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.

3 participants