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

Legacy Decorators + Generator Methods #9852

Closed
buschtoens opened this issue Apr 12, 2019 · 4 comments · Fixed by #9912
Closed

Legacy Decorators + Generator Methods #9852

buschtoens opened this issue Apr 12, 2019 · 4 comments · Fixed by #9912
Labels
Has PR i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser Spec: Decorators (Legacy)

Comments

@buschtoens
Copy link
Contributor

Bug Report

Current Behavior
Legacy decorators cannot decorate generator methods. An Unexpected token error is thrown:

/repl: Unexpected token (5:21)

  3 | class Foo {
  4 |   @deco
> 5 |   *generatorMethod() {}
    |                      ^
  6 | }

Input Code
REPL

function deco() {}

class Foo {
  @deco
  *generatorMethod() {}
}

Expected behavior/code
No error should be thrown and the method should be transpiled like normal methods.

Babel Configuration
Presets: es2015 + stage-2
Decorators: legacy

Environment
Babel version(s): 7.4.3

Possible Solution
#8742

Additional context/Screenshots
#5704, babel/babylon#382

@babel-bot
Copy link
Collaborator

Hey @buschtoens! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo
Copy link
Member

We should update our parser to wycats/javascript-decorators@e240cbc, so that we also match TS's behavior.

@buschtoens
Copy link
Contributor Author

I never meddled with the Babel parser, but I would like to help implement this. Can you provide some pointers?

@robclancy
Copy link

I don't understand how stage 1 decorators can be recommended over stage 2 while this bug exists. It's a now default JS feature that isn't compatible but was fixed in stage 2.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has PR i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser Spec: Decorators (Legacy)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants