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

buschtoens opened this Issue Apr 12, 2019 · 4 comments


None yet
4 participants
Copy link

commented Apr 12, 2019

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

function deco() {}

class Foo {
  *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

Babel version(s): 7.4.3

Possible Solution

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


This comment has been minimized.

Copy link

commented Apr 12, 2019

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
that typically always has someone willing to help. You can sign-up here
for an invite.


This comment has been minimized.

Copy link

commented Apr 15, 2019

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


This comment has been minimized.

Copy link
Contributor Author

commented Apr 23, 2019

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


This comment has been minimized.

Copy link

commented Apr 24, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.