Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed May 29, 2023
1 parent 961233c commit 7afa628
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
@@ -1,8 +1,8 @@
((a, {
b: _b = 0,
c = 3
c: _c = 3
}) => {
return a === 1 && _b === 2 && c === 3;
return a === 1 && _b === 2 && _c === 3;
})(1, {
b: 2
});
15 changes: 5 additions & 10 deletions packages/babel-traverse/src/scope/lib/renamer.ts
Expand Up @@ -27,20 +27,15 @@ const renameVisitor: Visitor<Renamer> = {
}
}
},
ObjectProperty(path: NodePath<ObjectProperty>) {
const { extra, key, value, computed, shorthand } = path.node;

if (computed) {
return;
}

if (!shorthand) {
return;
}
ObjectProperty(path: NodePath<ObjectProperty>, state) {
const { extra, value, shorthand } = path.node;

if ((key as Identifier).name !== (value as Identifier).name) {
if (shorthand && (value as Identifier).name === state.oldName) {
path.node.shorthand = false;
if (extra?.shorthand) extra.shorthand = false;
// if (extra?.shorthand) extra.shorthand = false;
// It will be then renamed by the ReferencedIdentifier visitor.
}
},

Expand Down

0 comments on commit 7afa628

Please sign in to comment.