speedskater / babel-plugin-rewire

A babel plugin adding the ability to rewire module dependencies. This enables to mock modules for testing purposes.
843 stars 90 forks source link

Breaks compilation when destructuring when assigning to an existing variable #189

Open jamietre opened 7 years ago

jamietre commented 7 years ago
let a
[a] = [1]

Valid ES6, but blows up with rewire:

TypeError: Property left of AssignmentExpression expected node to be of a type ["LVal"] but instead got "CallExpression"

Same problem with objects:

let a
({a} = { a: 'b'})

Works with creating a new variable:

let [a] = [1]
i-am-lioness commented 5 years ago

i'm still having this issue

kjs3 commented 5 years ago

Just hit this. Here's my lame little hack in the meantime.

let a,b

const { a: x, b: y } = myFunc()
a = x
b = y

:disappointed: