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

transform-object-rest-spread should not revisit member access #10743

JLHwung opened this issue Nov 20, 2019 · 1 comment

transform-object-rest-spread should not revisit member access #10743

JLHwung opened this issue Nov 20, 2019 · 1 comment


Copy link

@JLHwung JLHwung commented Nov 20, 2019

Bug Report

Current Behavior
transform-object-rest-spread will revisit member access when rest element appears in nested destructuring

Input Code

  • REPL or Repo link if applicable: REPL
var fooCount = 0;
var o = {
  get foo() {
    return { bar: 42 }
var {
  foo: {
} = o;


After transformed, fooCount prints 2.

Expected behavior/code
It should print 1.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
  "plugins": ["@babel/plugin-object-rest-spread"]


Possible Solution
Remove nested object pattern which contains spread element, combine this object pattern with the memoised member expression and create a new variable declarator.

Additional context/Screenshots
Credits to @nicolo-ribaudo who first discovers this issue in #10738 (comment)


This comment has been minimized.

Copy link

@babel-bot babel-bot commented Nov 20, 2019

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

@JLHwung JLHwung changed the title transform-object-reset-spread should not revisit member access transform-object-rest-spread should not revisit member access Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.