Skip to content

fix: destructuring transform to match correct order as native JS - #18395

Closed
joellemd wants to merge 5 commits into
babel:mainfrom
joellemd:fix/destructuring-object-pattern-order
Closed

joellemd wants to merge 5 commits into
babel:mainfrom
joellemd:fix/destructuring-object-pattern-order

Conversation

@joellemd

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? Fixes #18363, Fixes #18359, Fixes #18362
Patch: Bug Fix? Yes
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
Need backport? No
License MIT

Previously, generated assignments evaluate computed keys, target expressions and source properties in the wrong order when side effects were involved.

Changes

  1. Evaluate computed keys before evaluating assignment targets.
  2. Read nested source properties at the correct time and avoid duplicate getter calls.
  3. Evaluate member targets before reading source properties when defaults are used.
  4. Avoid unnecessary temporaries for constant keys and simple targets.

@github-actions

Copy link
Copy Markdown

Thanks for opening this pull request! 🎉

We really appreciate you taking the time to contribute, @joellemd.

A maintainer will take a look as soon as they can. In the meantime, please make sure that:

  • the description explains what changed and why
  • any related issues are linked
  • existing tests still pass

If anything needs adjusting we'll leave comments here. Thanks again!

@babel-bot

babel-bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/62555

@joellemd

Copy link
Copy Markdown
Contributor Author

Array destructuring with member targets and certain ...rest and super cases are not covered by this PR and will be addressed separately.

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

commit: c835c8c

@nicolo-ribaudo nicolo-ribaudo added the PR: Spec Compliance 👓 A type of pull request used for our changelog categories label Oct 23, 2026
@JLHwung

JLHwung commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

@joellemd Thank you for working on this issue. I am already working on a destructuring refactor that would fix most open destructuring issues. Welcome to review when the refactor work is ready.

@joellemd

Copy link
Copy Markdown
Contributor Author

Closing this as it's being worked on in #18416

@joellemd joellemd closed this Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Spec Compliance 👓 A type of pull request used for our changelog categories

Projects

None yet

4 participants