Cannot destructure function properties
cooperka opened this issue · 1 comments
cooperka commented
Take the following example:
import { fromJS } from 'immutable'
// Works as expected:
let { a, b: { c } } = fromJS({ a: 1, b: { c: 2 } })
console.log(a, c)
let barFn = () => {}
barFn.bar = 'baz'
// Works with plain JS, but fails with extensible-destructuring:
let { foo: { bar } } = { foo: barFn }
console.log(bar)
Destructuring a
and c
works fine, but trying to destructure bar
throws Error: cannot resolve property bar in object of type function (function barFn() {})
. Seems to be an easy fix by just changing the logic here: https://github.com/vacuumlabs/babel-plugin-extensible-destructuring/blob/master/runtime/src/runtime.js#L32-L34
I'll try to make a PR soon.
hleumas commented
Thanks! I will be grateful for PR.