vacuumlabs / babel-plugin-extensible-destructuring

Plugin for extensible destructuring in Babel
BSD 2-Clause "Simplified" License
117 stars 11 forks source link

Is there any ways to use this plugin with Flowtype? #21

Open FourwingsY opened 7 years ago

FourwingsY commented 7 years ago
  1. 
    type Test = Map<string, any>

const test: Test = Immutable.Map({...}) const { a, b, c } = test

`property 'a'. Property not found on Map.`

2. 

type Test = { a: number, b: number, c: string, }

const test: Test = Immutable.Map({...}) const a = test.get('a')

`Flow: property 'get'. Property not found in object type`

3. 

type Test = { get: Function, set: Function, a: number, b: number, c: string, } const test: Test = Immutable.Map({...}) const a = test.get('a') const { b, c } = test



this is OK but bit strange for use. if i use getIn or merge, I have to define that function also.
FourwingsY commented 7 years ago

I found some tricky ways to solve this

type Test = Map<string, any> & {
    a?: number,
    b?: number,
    c?: string,
}