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

Argument named `args` breaks the transpilation, but if is renamed to `x` works #7203

Closed
hackhat opened this Issue Jan 11, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@hackhat

hackhat commented Jan 11, 2018

Source code:

  setState = (state, fn) => {
    super.setState(state, (...args) => {
      fn(...args)
    });
  };

transpiles to:

  this.setState = function (state, fn) {
    super.setState(state, function () {
      fn.apply(undefined, arguments);
    });
  };

with error Uncaught SyntaxError: 'super' keyword unexpected here.

Looks like if you access the ...args it breaks the transpiler somehow.

If I change the argument args to x works:

  setState = (state, fn) => {
    super.setState(state, (...x) => {
      fn(...x);
    });
  };

Strange but somehow the variable name affects the code. Is there any way to see the transpiled code? I only able to see the eval string. I was able to see the code after eval, but only once and I'm not able to do it again.

I'm using:

@babel-bot

This comment has been minimized.

Show comment
Hide comment
@babel-bot

babel-bot Jan 11, 2018

Collaborator

Hey @hackhat! 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.

Collaborator

babel-bot commented Jan 11, 2018

Hey @hackhat! 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.

@jridgewell

This comment has been minimized.

Show comment
Hide comment
@jridgewell

jridgewell Apr 7, 2018

Member

This was fixed some time in Babel 7.

Member

jridgewell commented Apr 7, 2018

This was fixed some time in Babel 7.

@jridgewell jridgewell closed this Apr 7, 2018

@lock lock bot added the outdated label Jul 7, 2018

@lock lock bot locked as resolved and limited conversation to collaborators Jul 7, 2018

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