Open anka-213 opened 3 years ago
If I reconstruct it one level deeper it gives the correct parentheses again:
j('(a = b)[c]')
.find(j.MemberExpression)
.replaceWith(({node: {object: {operator,left,right}, property, computed}}) =>
j.memberExpression(j.assignmentExpression(operator,left,right), property, computed))
.toSource()
gives
'(a = b)[c]'
@anka-213 seems like you need to add object.extra.parenthised = true
to get correct (same) output
j('(a = b)[c]')
.find(j.MemberExpression)
.replaceWith(({node: {object, property, computed}}) => {
object.extra.parenthised = true
return j.memberExpression(object, property, computed)
})
.toSource()
Here is an example:
gives the result
instead of the expected