Skip to content

Commit

Permalink
address review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed May 5, 2022
1 parent d111dc4 commit 19fc82f
Showing 1 changed file with 5 additions and 4 deletions.
Expand Up @@ -3,8 +3,8 @@ import type { Scope } from "@babel/traverse";
import { types } from "@babel/core";
import type { File } from "@babel/core";
import { buildObjectExcludingKeys } from "@babel/plugin-transform-destructuring";
import { assignmentExpression, ObjectProperty } from "@babel/types";
const {
assignmentExpression,
binaryExpression,
conditionalExpression,
cloneNode,
Expand Down Expand Up @@ -49,12 +49,12 @@ function initRestExcludingKeys(pattern: t.LVal): ExcludingKey[] | null {
* memoising the computed non-static keys.
*
* @param {ExcludingKey[]} excludingKeys
* @param {ObjectProperty[]} properties An array of object properties that should be excluded by rest element transform
* @param {t.ObjectProperty[]} properties An array of object properties that should be excluded by rest element transform
* @param {Scope} scope Where should we register the memoised id
*/
function growRestExcludingKeys(
excludingKeys: ExcludingKey[],
properties: ObjectProperty[],
properties: t.ObjectProperty[],
scope: Scope,
) {
if (excludingKeys === null) return;
Expand Down Expand Up @@ -224,6 +224,7 @@ export function hasPrivateKeys(pattern: t.LVal) {
traversePattern(pattern, function* (node) {
if (isObjectProperty(node) && isPrivateName(node.key)) {
result = true;
// stop the traversal
yield;
}
}).next();
Expand Down Expand Up @@ -324,7 +325,7 @@ export function* transformPrivateKeyDestructuring(
if (searchPrivateKey.done) {
if (restExcludingKeys?.length > 0) {
// optimize out the rest element because `objectWithoutProperties`
// always return a new object
// returns a new object
// `{ ...z } = babelHelpers.objectWithoutProperties(m, ["x"])`
// to
// `z = babelHelpers.objectWithoutProperties(m, ["x"])`
Expand Down

0 comments on commit 19fc82f

Please sign in to comment.