Skip to content

refactor: overhaul destructuring lowering - #18416

Open
JLHwung wants to merge 138 commits into
babel:mainfrom
JLHwung:refactor-destructuring-lowering
Open

JLHwung wants to merge 138 commits into
babel:mainfrom
JLHwung:refactor-destructuring-lowering

Conversation

@JLHwung

@JLHwung JLHwung commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? Fixes #18348, Fixes #18349, Fixes #18350, Fixes #18351, Fixes #18352, Fixes #18359, Fixes #18362, Fixes #18363, Fixes #10743, Fixes #18196, Fixes #10735, Fixes #4647, Fixes #5600, Fixes #16969, Closes #10738, Closes #18395, Closes #17023, Closes #18388, Fixes #16470, Fixes #18594
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature? New packages: @babel/helper-create-destructuring-plugin, @babel/helper-named-evaluation
Tests Added + Pass? Yes
Documentation PR Link babel/website#3253 (Preview URL)
Any Dependency Changes? Yes: the three plugins now depend on the new helper instead of on each other
Need backport? No
License MIT

Disclaimer: I drafted the PR description with the help of LLM. I have read and edited the text.

Summary

transform-destructuring, transform-object-rest-spread and proposal-destructuring-private each had their own destructuring lowering, and they called into each other. Each one memoised computed keys, the right-hand side, rest exclusion lists and function parameters in its own way. Most of the open evaluation-order bugs come from these copies disagreeing, or from one of them evaluating something too early.

This PR adds @babel/helper-create-destructuring-plugin, a factory modelled after the @babel/helper-create-class-features-plugin, and reimplements the three plugins on top of it. Each plugin enables some feature flag (destructuring, objectRest, objectSpread, privateDestructuring). The enabled plugins share one lowering pass configured with the union of their flags, and only the instance using the newest helper version runs it.

How the lowering works

src/lowering.ts walks each pattern once, from left to right, and records a list of steps, think of it as something like intermediate representation:

  • Temp: a fresh temporary
  • Bind: a user binding, or a native sub-pattern kept as-is
  • Effect: an expression kept for its side effects only

Values are referenced lazily. Each read returns a placeholder, and only after the whole pattern has been walked does the lowering decide whether a value is inlined, stored in a temporary, or kept only for its side effects. A value gets a temporary when it is read more than once, or when something observable runs between its evaluation and its read. As a result, temporaries are created exactly where the spec evaluates the corresponding values. The plugin's own temporaries, including the ones declared by for-in/of heads, are known to never be reassigned, so they are read again instead of being copied.

When the destructuring feature is off (e.g. only object rest is enabled), the lowering runs in partial mode: everything that doesn't need lowering stays native. Object patterns are split into native chunks around the properties that must be lowered; a rest element stays native when the only lowered properties before it have private keys. Array patterns are rewritten from the first element that needs lowering.

Function parameters containing object rest or private keys are moved into the body. When moving them could change what the parameters see (a later default value, a body declaration shadowing a name they reference, a generator), convertFunctionParams from transform-parameters moves them instead. It now works out which of the following parameters must move too, so that default values and private brand checks are still evaluated in order.

Default names, including class names that static initializers can observe, are inferred in src/named-evaluation.ts.

Scope information is updated incrementally instead of re-crawling the scope after every lowered statement. The checkScopeInfo test helper checks in every fixture that the result is identical to a fresh crawl.

Spec fixes

After the destructuring logic is centralized, we fixed quite a few spec deviation, each in their own commit. They showcase that it is easier to fix destructuring bugs without having to sync the patch to potentially three plugins.

Fixture diff

About 805 fixture files change, including 243 new exec tests. 173 existing outputs change. Compared with main (ignoring whitespace), 77 are smaller, 6 are the same size, and 90 are larger. Where the old output was equivalent, the lowering was adjusted to produce it again: for example, identifier keys are read inline, Symbol.for(...) keys are evaluated again instead of being stored, and the rest element stays native after private keys. The remaining larger outputs are correctness fixes and uid style changes (such as _e to _ref)

Every fixture that only had an output.js in the three plugins now also has an exec test derived from its input, so these outputs are checked for behaviour, not only for shape. All the exec tests that Node.js can parse also pass natively.

Performance

Benchmark: benchmark/babel-plugin-transform-destructuring (Node.js >= 26, node run.mjs 5). It compares the published plugins against this branch on the same @babel/core. Most of the gain comes from not re-crawling scopes.

case baseline (ops/s) current (ops/s) current / baseline
destructuring 6.59 10.12 1.535
object-rest-spread 16.31 15.85 0.972
destructuring + object-rest-spread 3.81 5.99 1.571
destructuring-private 18.18 24.05 1.323

Node.js 26.10.0, 5 rounds, median of the per-round medians. The baselines are @babel/[email protected], @babel/[email protected] and @babel/[email protected]. object-rest-spread is about 3% slower: the old plugin didn't update the scope information at all, and keeping it exact costs about 11% of this case.

Known limitations

  • In partial mode, patterns nested inside array patterns are still destructured after the whole array has been iterated (there is a todo in lowering.ts). Iterators are consumed eagerly by the helpers, so next() and return() calls are not interleaved with the targets.
  • The iterator helper behaviours reported in Array destructuring reads the value of an elided iterator element #18345 and Array destructuring reads the iterator return property twice when closing #18346 are not addressed. The array helpers fast-path real arrays, ignoring a patched Array.prototype[Symbol.iterator]. I think they should be fixed in babel-helpers so I have left them on the table
  • objectWithoutProperties doesn't call Proxy traps in the spec order when it excludes keys.
  • Generators with lowered parameters are wrapped in a function that returns the generator, as transform-parameters does: their objects don't inherit from the outer function's prototype.
  • @babel/generator drops the parentheses of [(a) = function () {}] = [] when the pattern isn't lowered, which changes the function's name. This should be fixed on the generator.
  • With a direct eval in the body, moved parameters are declared with var (see above), so they lose their TDZ: function f({ b = a, a, ...r }) { eval(""); } doesn't throw for f({}).
  • useBuiltIns precedence: with transform-destructuring also enabled, its false default overrides proposal-destructuring-private's useBuiltIns: true.
  • The scope information of a lowered node is forgotten from every same-named binding in the enclosing scopes, which costs about 1–2% on the benchmark. It could stop at the first binding unless the node is in the parameter list of that binding's function.

Follow-ups

  • Consider remove the buildObjectExcludingKeys and unshiftForXStatementBody export from the transform-destructuring plugin in Babel 9. They are now exported from the destructuring helper. We can start deprecating these 2 imports from Babel 8.
  • Consider a new compiler assumption setRestProperties: assign copied properties to a fresh rest object as if defining own data properties, so we can get rid of objectWithoutProperties and Object.create(null) in the common shallow copy output var { ...copy } = source.

/cc @joellemd if you are interested.

@JLHwung JLHwung added PR: Internal 🏠 A type of pull request used for our changelog categories PR: Needs Docs labels Oct 25, 2026
@babel-bot

babel-bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

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

@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

commit: 3378a8f

(_C$x => {
var x;
result = (_m = _C, _m2 = babelHelpers.assertClassBrand(_C, _m, _x)._, x = _m2 === void 0 ? 2 : _m2, _m);
result = (_C$x = _x._, x = _C$x === void 0 ? 2 : _C$x, _C);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an output optimization: Compared with the main, the destructuring lowering no longer copies static values to temporaries, so instead of _m = _C; _m.#x it now reads C.#x directly. When the receiver is the class reference itself, the class features transform skips the brand check (skipCheck in helper-create-class-features-plugin/src/fields.ts). The output is the same as writing C.#x by hand in the class.

var x, z;
[..._p] = [_C], _m = babelHelpers.assertClassBrand(_C, _p[0], _x)._, x = _m === void 0 ? 1 : _m, z = babelHelpers.objectWithoutProperties(_p, _excluded);
[..._ref] = [_C];
var _ref$0$x = babelHelpers.assertClassBrand(_C, _ref[0], _x)._;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lowering helper now generates several variable declarations, let me know if you prefer the previous single variable declarations approach.

c = babelHelpers.objectWithoutPropertiesLoose(obj, [_a].map(babelHelpers.toPropertyKey));
let _obj = obj,
{
[_a = babelHelpers.toPropertyKey(a)]: b

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a correctness fix, toPropertyKey is now applied before b is destructured.

@@ -1,11 +1,11 @@
(_ref, a) => {
let R = babelHelpers.extends({}, (babelHelpers.objectDestructuringEmpty(_ref), _ref));
let R = babelHelpers.objectWithoutProperties(babelHelpers.extends(Object.create(null), (babelHelpers.objectDestructuringEmpty(_ref), _ref)), []);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit unfortunate correctness fix. The new helpers are introduced to preserve an own __proto__ and the proxy trap order. We may consider a new compiler assumption:

setRestProperties: assign copied properties to a fresh rest object as if defining own data properties, so we can get rid of objectWithoutProperties and Object.create(null).

@JLHwung

JLHwung commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author


const visitor = buildDestructuringVisitor(guard);

if (feature & (FEATURES.objectRest | FEATURES.privateDestructuring)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var o = { ...a };
function f({ ...rest }) {}
var { x, ...y } = o;

Output when both plugins use the same helper version:

var o = _objectSpread({}, a);
function f(_ref) {
  var rest = _objectWithoutProperties(Object.assign(Object.create(null), (_objectDestructuringEmpty(_ref), _ref)), []);
}
var x = o.x,
  y = _objectWithoutProperties(o, ["x"]);

Output when transform-destructuring uses a newer helper version:

var o = {
  ...a
};
function f({
  ...rest
}) {}
var x = o.x,
  y = _objectWithoutProperties(o, ["x"]);

Merging @babel/plugin-transform-destructuring and @babel/plugin-transform-object-rest-spread into a shared helper means only the newest helper copy runs. However, each plugin registers Function and ObjectExpression handlers only for its own features. If the newest copy belongs to transform-destructuring it doesn't register the handlers needed for object spread and parameter rest. The older transform-object-rest-spread copy is disabled which leaves the first two statements uncompiled without warning. Meanwhile, the destructuring statement is still transformed. This can break older browsers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed in the new commit.

* parameter list non-simple, with an unused rest element, which changes
* neither the function's `length` nor the arguments.
*/
function keepArgumentsUnmapped(path: NodePath<t.Function>) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setter with arguments becomes a syntax error. With only transform-object-rest-spread enabled, a sloppy setter that uses arguments gets an extra rest parameter, for example:

var o = { set x({a, ...b}) { arguments; } };
// PR output
set x(_ref, ..._unmapped) { ... }   // SyntaxError: Setter must have exactly one formal parameter

v8.0.1 plugin outputs set x(_ref) and parses fine, so this is a regression. keepArgumentsUnmapped appends the ..._unmapped rest parameter to any sloppy function whose parameters are all identifiers after lowering, including setters. It doesn't happen when transform-destructuring is also enabled, because the arguments check is skipped then.

Maybe skip setters or find another way to keep arguments unmapped?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, yeah we should skip setters. Since the setters must have only one parameter, the mapping is not observable anyway.

@JLHwung
JLHwung requested review from joellemd and a balanced review from Copilot and removed request for joellemd October 25, 2026 21:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

One or more issues must be addressed before approval.

1 open issue
What changed in this PR

This PR centralizes destructuring lowering in a shared helper used by the destructuring, object-rest/spread, and private-destructuring plugins.

Changes:

  • Wire the shared helper into plugin dependencies and TypeScript project references, and expose parameter-analysis utilities.
  • Preserve own __proto__ properties when copying object-rest values.
  • Update generated-output fixtures and expand execution, evaluation-order, scope, and TypeScript regression coverage.

For compactness, table prefixes expand to these directories under packages/:

H = babel-helper-create-destructuring-plugin; D = babel-plugin-transform-destructuring; O = babel-plugin-transform-object-rest-spread; P = babel-plugin-transform-parameters; V = babel-plugin-proposal-destructuring-private; E = babel-plugin-transform-explicit-resource-management; X = babel-plugin-proposal-discard-binding; Env = babel-preset-env; TS = babel-plugin-transform-typescript; React = babel-plugin-transform-react-constant-elements; Async = babel-plugin-transform-async-generator-functions; Helpers = babel-helpers.

File Description
tsconfig.paths.json Updated as part of this pull request.
tsconfig.json Updated as part of this pull request.
packages/​babel-preset-env/​test/​fixtures/​sanity/​block-scoping-for-of/​output.js Updated as part of this pull request.
packages/​babel-preset-env/​test/​fixtures/​plugins-integration/​regression-4855/​output.js Updated as part of this pull request.
packages/​babel-preset-env/​test/​fixtures/​plugins-integration/​issue-15012/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-typescript/​test/​fixtures/​regression/​10338/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-react-constant-elements/​test/​fixtures/​integration/​issue-12303/​output.mjs Updated as part of this pull request.
packages/​babel-plugin-transform-parameters/​test/​fixtures/​regression/​11256/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-parameters/​test/​fixtures/​parameters/​default-ts-this-parameter/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-parameters/​test/​fixtures/​parameters/​default-ts-this-parameter/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-parameters/​test/​fixtures/​parameters/​default-ts-this-parameter/​input.ts Updated as part of this pull request.
packages/​babel-plugin-transform-parameters/​test/​fixtures/​assumption-ignoreFunctionLength/​default-array-destructuring/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-parameters/​test/​fixtures/​assumption-ignoreFunctionLength/​complex-assignment/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-parameters/​src/​index.ts Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​tsconfig.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​helpers/​checkScopeInfo.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​regression/​T7178/​props.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​regression/​T7178/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​regression/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​regression/​gh-8323/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-spread/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-spread-loose/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-spread-loose-builtins/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​symbol/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-type-annotations/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-type-annotations/​input.ts Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-ts-this-parameter/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-ts-this-parameter/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-ts-this-parameter/​input.ts Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-shadowed-default/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-shadowed-default/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-shadowed-default/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-outer-binding-shadowed/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-outer-binding-shadowed/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-outer-binding-shadowed/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-lowered-default-order/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-later-default-order/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-conflict-rest-param/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-arrow-new-arrow-check/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​parameters-arrow-new-arrow-check/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​null-destructuring/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​null-destructuring-transform-destructuring/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​nested/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​nested/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​for-x-completion-record/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​for-x-completion-record/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​export/​output.mjs Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​duplicate-decl-bug/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​declare-destructuring/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​declare-destructuring/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​declare-destructuring/​input.ts Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​object-rest/​assignment-expression/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-setSpreadProperties/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-setSpreadProperties-with-useBuiltIns/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-pureGetters/​rest-unused-null-check/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-pureGetters/​rest-unused-null-check/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-pureGetters/​rest-unused-null-check/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-pureGetters/​rest-unused-computed-keys/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-pureGetters/​rest-unused-computed-keys/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-pureGetters/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-objectRestNoSymbols/​rest-var-declaration/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-objectRestNoSymbols/​rest-computed/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-objectRestNoSymbols/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-object-rest-spread/​test/​fixtures/​assumption-ignoreFunctionLength/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-explicit-resource-management/​tsconfig.json Updated as part of this pull request.
packages/​babel-plugin-transform-explicit-resource-management/​src/​index.ts Updated as part of this pull request.
packages/​babel-plugin-transform-explicit-resource-management/​package.json Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​tsconfig.json Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​sourcemap/​declaration-loc/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​sourcemap/​assignment-loc/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​sourcemap/​assignment-loc/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​sourcemap/​assignment-loc/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​regression/​8528/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​regression/​18210/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​regression/​18210/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​regression/​11210/​output.mjs Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​regression/​11210/​exec.mjs Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​scope-info-nested-violations/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​scope-info-nested-violations/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​object-rest-literal-computed-keys/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​hoisted-temp-in-loop-and-catch/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​for-init-multiple-steps/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​for-init-multiple-steps/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​export-declaration/​output.mjs Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​export-declaration/​input.mjs Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​default-class-name-accessor/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​default-class-name-accessor/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​default-class-name-accessor/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​assignment-nested-rest-member-target/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​assignment-nested-rest-member-target/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​arrow-assignment-hoisted-temp/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​arrow-assignment-hoisted-temp/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​arrow-assignment-hoisted-temp/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​array-rest-pattern-nested-default/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​array-rest-pattern-nested-default/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​array-rest-pattern-nested-default/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​array-literal-safe-elements/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​array-literal-holes/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​array-literal-holes/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​arguments/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​edge-cases/​arguments/​input.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​options.json Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​object-rest-impure-computed-keys/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​object-basic/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​multiple/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​mixed/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​member-expression/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​known-array/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​issue-6373/​some-module.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​issue-6373/​exec.mjs Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​issue-5744/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​issue-5628/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​issue-3081/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​init-hole/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​for-of-shadowed-block-scoped/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​for-let/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​for-let/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​for-let-nest/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​for-let-nest/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​empty/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​empty/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​empty-string/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​const/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​check-no-hoisting-when-using-template-strings/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​assignment-statement/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​assignment-sequence-expression-completion-record/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​assignment-expression/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​assignment-expression-pattern/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​assignment-expression-pattern/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​assignment-expression-completion-record/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​assignment-arrow-function-no-block/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​assignment-arrow-function-block/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​array/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​destructuring/​array/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​assumption-objectRestNoSymbols/​rest-var-declaration/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​assumption-objectRestNoSymbols/​rest-computed/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​assumption-objectRestNoSymbols/​rest-computed/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​assumption-iterableIsArray/​basic/​exec.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​assumption-arrayLikeIsIterable/​simple/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​test/​fixtures/​allowArrayLike/​simple/​output.js Updated as part of this pull request.
packages/​babel-plugin-transform-destructuring/​package.json Updated as part of this pull request.
packages/​babel-plugin-transform-async-generator-functions/​test/​fixtures/​regression/​5880/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-discard-binding/​test/​fixtures/​integration-object-rest-spread/​function-parameters/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-discard-binding/​test/​fixtures/​integration-object-rest-spread/​access-side-effect/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-discard-binding/​test/​fixtures/​integration-object-rest-spread-assumption-pureGetters/​basic/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-discard-binding/​test/​fixtures/​integration-destructuring/​function-parameters/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​tsconfig.json Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​helpers/​checkScopeInfo.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​variable-declaration/​options.json Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​variable-declaration/​basic/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​variable-declaration--es2015/​object-rest-and-keys/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​variable-declaration--es2015/​basic/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​typescript/​valid-before-destructuring-private/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​ordering/​options.json Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​outer-binding-shadowed-in-body/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​outer-binding-shadowed-in-body/​input.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​outer-binding-shadowed-in-body/​exec.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​options.json Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​no-shadowed-params/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​later-default-order/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​later-default-order/​input.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​default-references-private-binding/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​default-references-private-binding/​input.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​default-references-private-binding/​exec.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​arrow-new-arrow-check/​options.json Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​function-params/​arrow-new-arrow-check/​input.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​for-of/​options.json Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​for-of/​lhs/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​for-of--es2015/​lhs/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​for-init/​variable-declaration-with-assign/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​for-init/​options.json Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​for-init/​lhs/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​for-init/​lhs-with-assign/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​for-init--es2015/​lhs/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​catch-param/​no-shadowed-params/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​catch-param--es2015/​no-shadowed-params/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​assignment/​options.json Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​assignment/​object-rest-under-private/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​assignment/​object-rest-and-private-keys/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​assignment/​object-rest-and-keys/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​assignment/​member-expression/​output.js Updated as part of this pull request.
packages/​babel-plugin-proposal-destructuring-private/​test/​fixtures/​assignment/​completion-do-expression/​output.js Updated as part of this pull request.
packages/​babel-helpers/​src/​helpers/​objectWithoutPropertiesLoose.ts Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​index.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​helpers/​checkScopeInfo.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​well-known-symbol-keys/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​well-known-symbol-keys/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​well-known-symbol-keys/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​void-rest-null-check/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​void-rest-null-check/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​void-rest-null-check/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​void-rest-null-check/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​void-pattern/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​void-pattern/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​void-pattern/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​unrelated-body-declarations/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​unpacked-rest-node-ownership/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​unpacked-rest-node-ownership/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​unpacked-rest-node-ownership/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​this-null-check/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​this-null-check/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​this-null-check/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​shadowed-symbol-key/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​shadowed-symbol-key/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​param-closure-redeclared-param/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​object-spread-proto-after-spread/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​object-spread-proto-after-spread/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​object-rest-key-coerced-once/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​object-rest-key-coerced-once/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​object-rest-computed-key-after-binding/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​object-rest-computed-key-after-binding/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​null-check-initialized-key/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​null-check-initialized-key/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​null-check-before-key-getter/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​null-check-before-key-getter/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​null-check-before-key-getter/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​null-check-before-key-coercion/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​null-check-before-key-coercion/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​null-check-before-key-coercion/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​null-check-before-computed-key/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​null-check-before-computed-key/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​nested-object-rest-getter-once/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​nested-assignment-target-order/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​nested-assignment-target-order/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​mutable-generated-rhs/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​mutable-generated-rhs/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​mutable-generated-rhs/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​member-target-coercible-check/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​member-target-coercible-check/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​hoisted-var-in-switch-in-loop/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​hoisted-var-in-switch-in-loop/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​hoisted-var-in-switch-in-loop/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​global-class-name-type-annotations/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​global-class-name-type-annotations/​input.ts Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​for-of-head/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​for-of-head-shadowed-global/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​for-of-head-shadowed-global/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​for-init-function-name/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​for-init-function-name/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​export-destructuring-referenced/​output.mjs Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​export-destructuring-referenced/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​export-destructuring-referenced/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​export-destructuring-referenced/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​export-class-default-named-proto/​output.mjs Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​export-class-default-named-proto/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​export-class-default-named-proto/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​export-class-default-named-proto/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​explicit-parenthesized-functions/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​explicit-parenthesized-functions/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​empty-pattern/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​empty-pattern/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​empty-pattern/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​default-parenthesized-target-name/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​default-parenthesized-target-name/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​default-anonymous-function-name/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​computed-void-key-parameters/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​computed-void-key-parameters/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​computed-void-key-parameters/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​computed-void-key-effects/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​computed-void-key-effects/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​class-default-with-class-transforms/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​class-default-with-class-transforms/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​catch-param/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​catch-param/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​catch-param/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​catch-param-shadowed-by-body/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​binary-expression-keys-and-elements/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​binary-expression-keys-and-elements/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-member-target-after-rhs/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-key-getter-before-target/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-key-getter-before-target/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-key-coercion-before-target/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-key-coercion-before-target/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-in-sequence-completion/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-in-sequence-completion/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-default-member-target-order/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-default-member-target-computed-key/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-computed-key-before-member-target/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-computed-key-before-member-target/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​assignment-computed-key-before-member-target/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-writes-target/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-void-element-effects/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-void-element-effects/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-void-element-effects/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-rhs-evaluated-first/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-nested-pattern-effects/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-nested-member-target/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-default-coercion/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-default-coercion/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-default-coercion/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-constructor-effects/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-constructor-effects/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-constructor-effects/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-completion-value/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-completion-value/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​array-literal-completion-value/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​arguments-binding/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​spec-compliance/​arguments-binding/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​private/​void-private-key/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​private/​void-private-key/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​private/​void-private-key/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​private/​void-after-lowered-element/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​private/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​void-after-lowered-element/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​void-after-lowered-element/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​sloppy-arguments-unmapped/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​sloppy-arguments-unmapped/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​sloppy-arguments-setter/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​sloppy-arguments-setter/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​sloppy-arguments-eval/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​sloppy-arguments-eval/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​sloppy-arguments-eval/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​sloppy-arguments-eval/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​pure-getters-reassigned-binding/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​pure-getters-reassigned-binding/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​pure-getters-reassigned-binding/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​pure-getters-computed-key-kept/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​pure-getters-computed-key-kept/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​pure-getters-computed-key-kept/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​pure-getters-computed-key-kept/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​param-redeclared-var/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​param-redeclared-var/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​param-default-references-earlier-param/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​param-default-outer-binding-shadowed/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​param-default-outer-binding-shadowed/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​param-default-outer-binding-shadowed/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​object-rest-key-coerced-once/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​object-rest-key-coerced-once/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​null-check-before-computed-key/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​null-check-before-computed-key/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​nested-array-elements-in-order/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​nested-array-elements-in-order/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​nested-array-elements-in-order/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​generator-params-evaluated-on-call/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​generator-params-evaluated-on-call/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​assignment-member-target-chunk/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​arrow-body-visited-by-other-plugins/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​arrow-body-visited-by-other-plugins/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​arrow-body-visited-by-other-plugins/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​object-rest-only/​arrow-body-visited-by-other-plugins/​exec.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​all-features/​private-void-rest-null-check/​output.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​all-features/​private-void-rest-null-check/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​all-features/​private-void-rest-null-check/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​all-features/​private-rest-and-arrays/​input.js Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​test/​fixtures/​all-features/​options.json Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​README.md Updated as part of this pull request.
packages/​babel-helper-create-destructuring-plugin/​.npmignore Updated as part of this pull request.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The changes require final human review because they are too complex or risky for automated approval.

1 open issue

Review effort: Balanced

@JLHwung
JLHwung force-pushed the refactor-destructuring-lowering branch 2 times, most recently from ffe69da to 4aefd4c Compare October 26, 2026 01:58
@wawieyes-png

This comment was marked as spam.

if (restNodes) {
// The destructuring of the rest parameter happens after it is initialized
path.ensureBlock();
(node.body as t.BlockStatement).body.unshift(...restNodes);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something failing here, I confirmed the failure but I haven't traced why.

function f({ ...d } = {}, ...[x]) { var x = 5; return x; }

main: 5
PR: build error, Duplicate declaration "x"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, so what's happening here is that: with an IIFE-wrapped body, the convertFunctionRest also creates its own IIFE and then put the rest pattern's destructuring inside. Doing so eventually collides with the outer IIFE's parameters. I will fix this as well.

JLHwung and others added 29 commits November 24, 2026 20:03
- Move the `let`/`const` bindings of a lowered pattern to the new
  declaration instead of creating them again and copying their references
  and constant violations (`var` bindings are still created again, which
  makes the ones declared in a loop non-constant).
- Walk declared identifiers without allocating (`forEachAssignedIdentifier`)
  instead of `t.getBindingIdentifiers`, and only look for redeclarations
  in `var` declarators, the only ones that can redeclare a binding.
- Skip the conflict traversal of parameters that only bind names.

`trackDeclaredBindings` now also compares the binding's path, since a moved
binding keeps its identifier.

About 7% faster on the object-rest-spread benchmark input.

Assisted-by: Claude Opus 5.5
When the body of an async function is moved into an IIFE (e.g. a rest
parameter redeclared by a body function), the function becomes
synchronous and its errors are rejected by a `try` statement. The
parameters initialized afterwards were inserted before it, so they threw
synchronously:

  async function f({ x }, ...rest) { function rest() {} }
  f(null); // threw instead of returning a rejected promise

The `try` statement is now recorded on the function, and `getParamsInitBlock`
returns it as the place to initialize the parameters, for the declarations
of convertFunctionParams, the rest parameter and the patterns moved by the
destructuring helper (when transform-parameters runs first). A second IIFE,
e.g. for a default value reading a body declaration, is created inside it.

Assisted-by: Claude Opus 5.5
transform-parameters initializes a moved parameter with a conditional
expression, which doesn't name an anonymous function or class default:

  function f({ ...r }, C = class { static saved = this.name }) {}
  // C.saved was "" instead of "C"

object-rest-spread now moves the parameters following a lowered one, so
this also affected it. The defaults are named with `buildNamedDefault`,
moved from the destructuring helper to transform-parameters along with
`isAnonymousFunctionDefinition` and `isIdentifierRef`: classes are
defined as `{ C: class {} }.C`, named before their static initializers
run, and functions are wrapped in `setFunctionName`.

`isAnonymousFunctionDefinition` now skips the transparent expression
wrappers (TypeScript and Flow type assertions, as well as parentheses),
which are removed from the output.

Assisted-by: Claude Opus 5.5
Move the NamedEvaluation utilities to their own helper package:
`isAnonymousFunctionDefinition`, `isIdentifierRef` and `buildNamedDefault`
(from transform-parameters) and `preventNamedEvaluation` (from the
destructuring helper). transform-parameters, the destructuring helper and
explicit-resource-management import them from it, instead of
transform-parameters and the destructuring helper exporting them.

Assisted-by: Claude Opus 5.5
When only some parameters are moved into the body, the ones staying in
the list keep their own bindings while the list has expressions: a body
`var` or function declaration redeclaring them is a separate binding,
which the closures of the parameter list don't see. Removing a bare
`var` redeclaring them merged the two bindings:

  function f({ ...rest }, read = () => value, value, last = value) {
    var value;
    value = 2;
    return read(); // was 2 instead of 1
  }

The redeclarations of the retained parameters are now kept, and the body
is only moved into an IIFE receiving them when a moved parameter
references them. When the remaining list becomes simple, the bindings
merge again and they are handled like the moved parameters.

Assisted-by: Claude Opus 5.5
Stop the traversal by returning `t.traverseFast.stop` instead of throwing
a sentinel. `t.traverseFast` doesn't track ancestors: each child is
visited by a nested traversal, with the ancestors kept in the state, so
references are still told apart from property keys with the parent and
grandparent.

Assisted-by: Claude Opus 5.5
`scope.isPure` now accepts the unshadowed `undefined`, `NaN` and
`Infinity` globals and sequences of pure expressions, and rejects
`delete`, which removes a property. Expressions that only throw, like
`+1n` or `1 in 2`, have no side effects and stay pure.

`isDefaultEvaluationObservable` starts from `isPure` and only adds what
reordering can observe: the reads of bindings, which may be reassigned
or in their TDZ, conversions that could run user code, and expressions
that throw. `-`, `+` and `~` of primitive literals are not observable
anymore, except `+1n`: e.g. a `[-1]` computed key of an object rest
pattern is now read directly.

Assisted-by: Claude Opus 5.5
`readsMappedArguments` skipped every nested non-arrow function, including
the computed keys and decorators of methods, which are evaluated in the
enclosing function. When the parameters were moved into the body, the
`arguments` object read there became mapped:

  function f(a, { ...r }) {
    a = 2;
    return { [arguments[0]]() {} }; // key was "2" instead of "1"
  }

Use `environmentVisitor`, which requeues them.

Assisted-by: Claude Opus 5.5
`arguments.callee` and `arguments["callee"]` were both detected, but only
`arguments.length` was known not to be mapped: `arguments["length"]`
unmapped the `arguments` object for nothing. Also rename `isLoose` to
`isLooseFunctionLength`.

Assisted-by: Claude Opus 5.5
`arguments[0]()` calls the element with `arguments` as `this`, which can
write through the mapping of the parameters, but it was only counted as
an element read: without assigned parameters, `arguments` became mapped
when the parameters were moved into the body.

  function f(fn, b, { ...r }) {
    arguments[0](); // `this[1] = 2` changed `b`
    return b;
  }

Count the callees of calls, optional calls and tagged templates as
escapes, like writes. A computed key of an object pattern is only read,
not written.

Assisted-by: Claude Opus 5.5
The accessors following a spread were all defined with `defineAccessor`
since copying the descriptors of an object literal replaces an earlier
accessor with the same key: `{ get x() {}, ...{}, set x(v) {} }` lost its
getter. The spreads only define data properties, so copying the full
descriptor of an accessor is only observable when an earlier accessor of
the literal has the same key, or a computed one. Keep the other accessors
in the copied object literal again, like before, unless the properties
are copied with [[Get]] (`setSpreadProperties`, `pureGetters`):

  ({ ...a, get foo() {}, get bar() {} })
  // objectSpread2(objectSpread2({}, a), {}, { get foo() {}, get bar() {} })

Assisted-by: Claude Opus 5.5
…ater

In partial lowering, the elements following the first array element
that needs lowering were kept in the untranspiled pattern unless they
read a binding of the hoisted ones. They were then bound before the
hoisted element was destructured, which can throw (a brand check, a
null rest source) or run user code (a getter, a default) observing
them. Hoist them all again, as proposal-destructuring-private did on
main; this also fixes the same bug of transform-object-rest-spread on
main. A nested array pattern as the first lowered element is split in
turn rather than hoisted whole, as on main, so that it is still
iterated before the outer iterator is closed.

  [{ #x: x }, ...z] = [C];
  // before: [_ref, ...z] = [C], x = _ref.#x;
  // after:  [_ref, ..._ref2] = [C], x = _ref.#x, z = _ref2;

  const [, { p: void, ...rest1 }, ...rest2] = arr;
  // before: const [, _ref, ...rest2] = arr, ...;
  // after:  const [, _ref, ..._ref2] = arr, ..., rest2 = _ref2;

  const [a, [{ b, ...c }], ...] = x;
  // before: const [a, _ref, ...] = x, [_ref4] = _ref, { b } = _ref4, ...
  // after:  const [a, [_ref], ...] = x, { b } = _ref, ...

Assisted-by: Claude Opus 5.5
When a lowered pattern with a default value is replaced with a
temporary, either as the first hoisted element of an array pattern or
as a parameter moved into the function body, its default value became
the initializer of that temporary: an anonymous function was then
named `_ref` instead of "". Wrap it as `(0, fn)` like other
defaults moved out of their binding. With proposal-destructuring-private
this was a regression from main; transform-object-rest-spread had the
same bug on main.

  var [{ name, ...r } = function () {}] = [];
  // before: var [_ref = function () {}] = [], ...; // name === "_ref"
  // after:  var [_ref = (0, function () {})] = [], ...; // name === ""

Assisted-by: Claude Opus 5.5
`isCompletionObservable` stopped at a `break` or `continue` only in the
innermost statement list, then went on checking the statements of the
outer lists, which the jump skips. A later statement producing a value
there made the completion value of the assignment look unobservable,
so it was dropped, while main always kept it. After a `break` or
`continue`, conservatively assume the value is kept.

  var a, o = { a: 1 };
  switch (1) { case 1: ({ a } = o); break; case 2: 5; }
  // before: a = o.a; break;          -> completion 1
  // after:  a = (_o = o).a, _o; break;    -> completion { a: 1 }

The same check chooses the form of for-in/of assignment heads, which
now keep the value of the loop out of the completion in this case too.

Assisted-by: Claude Opus 5.5
A pattern parameter following one moved into the body must be
destructured after it, since its getters or iterator can run user
code. That made the whole parameter list go through
convertFunctionParams, which reads defaults from `arguments` and so
turned arrow functions into constructible functions. Move such a
pattern into the body right after the lowered ones instead, keeping
its default value in the list when evaluating it earlier can't run
user code. Its references are forgotten before it is registered again
through its new path, since it isn't lowered afterwards, and the
conflict check now also tracks the array patterns being moved.

  ({ ...R }, { a = R => R } = { b: R => R }) => {};
  // before: (function (_ref1) { let R = ...;
  //           let { a = R => R } = arguments.length > 1 && ... ; });
  // after:  (_ref1, _ref10 = { b: R => R }) => { let R = ...;
  //           let { a = R => R } = _ref10; };

Assisted-by: Claude Opus 5.5
RequireObjectCoercible runs before the rest target is evaluated, but a
rest element without excluded keys left the check to the object rest
helper, which only runs after a member target is evaluated. So
`({ ...missing.x } = null)` threw a ReferenceError instead of a
TypeError, and `({ ...f().p } = null)` called `f`. Main checked it
first, with `({} = _ref)`. Check it first again when the rest target
is a member expression.

  ({ ...target().value } = source);
  // before: _source = source, target().value = owp(..._source...);
  // after:  _source = source, {} = _source, target().value = owp(...);

Assisted-by: Claude Opus 5.5
A pattern parameter following one moved into the body is moved after
it when its default value can't run user code. A direct `eval` in the
pattern (a nested default, a computed key, or a closure) then ran in
the body scope and saw its declarations, unlike main and native.
Don't move such a pattern: it falls back to staying in the list, or to
convertFunctionParams when its evaluation is observable, as before.

  var x = "outer";
  function f({ ...r }, { a = eval("x") }) { var x = "inner"; return a; }
  // before: f({}, {}) === undefined (`eval` reads the body's `x`)
  // after:  f({}, {}) === "outer"

Assisted-by: Claude Opus 5.5
Since the elements following a lowered array element are all hoisted,
a nested array pattern among them was replaced by one temporary and
iterated after the outer iterator was closed: its `return()` (or a
generator's `finally` cleanup) ran before the inner iteration, unlike
main and native. Keep such an array pattern in place and hoist its
elements instead, recursively, so that it is iterated while the outer
iterator is still open and its targets are still bound after the
lowered element is destructured.

  var [{ ...r }, [a]] = it;
  // before: var [_ref, _ref2] = it, r = ..., [a] = _ref2;
  // after:  var [_ref, [_ref2]] = it, r = ..., a = _ref2;

Assisted-by: Claude Opus 5.5
A later nested array pattern was kept in place with all its elements
hoisted, so its defaults and nested patterns only ran after its iterator
was exhausted and closed: an element which throws didn't stop the
iteration, and the generator ran code that it never runs natively.
Keep it in place only when it binds identifiers (nothing runs between its
iterator steps), and hoist other array patterns whole again.

  var [{ ...r }, [[a] = null, b]] = [{}, gen()];
  // before: var [_ref, [_ref2, _ref3]] = ..., [a] = _ref2 === void 0 ? null : _ref2
  //         (`gen` is resumed past the throwing element)
  // after:  var [_ref, _ref2] = ..., [[a] = null, b] = _ref2

Assisted-by: Claude Opus 5.5
`isLoweredProperty` becomes `propertyNeedsLowering`, and the previous
`propertyNeedsLowering`, which also checks the property value, becomes
`propertyNeedsLoweringDeep`.

Assisted-by: Claude Opus 5.5
A computed key stored in a temporary was named after the
`toPropertyKey(key)` call wrapping it. Name it after the key itself,
as main did and as the inline memoised keys of untranspiled patterns
already are.

  let { [a]: b, ...c } = obj;
  // before: let _babelHelpers$toPrope = babelHelpers.toPropertyKey(a), ...
  // after:  let _a = babelHelpers.toPropertyKey(a), ...

Assisted-by: Claude Opus 5.5
Name classes after the binding when it differs from the key, and leave
them anonymous for member and pattern targets. Destructure multiple
bindings in the body of a for-of/in loop, including a rest element that
needs several statements and a head whose defaults read one name the
body redeclares.

Assisted-by: Claude Opus 5.5
@JLHwung
JLHwung force-pushed the refactor-destructuring-lowering branch from 1ee6045 to 3378a8f Compare November 25, 2026 01:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Internal 🏠 A type of pull request used for our changelog categories

Projects

None yet

6 participants