Skip to content

Commit f53d618

Browse files
yangyonglunJuniorTour
authored andcommitted
fix: Identifier in computed OptionalMemberExpression
1 parent 79532e7 commit f53d618

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function shouldPrependVm(path) {
4040
((_scope$path = scope.path) === null || _scope$path === void 0 ? void 0 : _scope$path.listKey) !== 'params' // not a id of a Declaration:
4141
&& !(t$1.isVariableDeclarator(parent) && parent.id === node) // not a param of a function
4242
&& !(t$1.isFunctionExpression(parent) && parent.params.indexOf(node) > -1) // not a property of OptionalMemberExpression
43-
&& !(t$1.isOptionalMemberExpression(parent) && parent.property === node) // not a key of Property
43+
&& !(t$1.isOptionalMemberExpression(parent) && parent.property === node && !parent.computed) // not a key of Property
4444
&& !(t$1.isObjectProperty(parent) && parent.key === node) // not a property of a MemberExpression
4545
&& !(t$1.isMemberExpression(parent) && parent.property === node && !parent.computed) // not in an Array destructure pattern
4646
&& !t$1.isArrayPattern(parent) // not in an Object destructure pattern

src/plugins/utils/shouldPrependVM.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function shouldPrependVm(path) {
3232
// not a param of a function
3333
&& !(t.isFunctionExpression(parent) && parent.params.indexOf(node) > -1)
3434
// not a property of OptionalMemberExpression
35-
&& !(t.isOptionalMemberExpression(parent) && parent.property === node)
35+
&& !(t.isOptionalMemberExpression(parent) && parent.property === node && !parent.computed)
3636
// not a key of Property
3737
&& !(t.isObjectProperty(parent) && parent.key === node)
3838
// not a property of a MemberExpression

0 commit comments

Comments
 (0)