I see that ImmutableJS has flow type annotations now but how do I define the type? For example:
const state : ??? = Immutable.fromJS({ name: 'chet', tags: ['something']})
I can define the type from normal JS but how do I say that this is an Immutable.Map with certain keys?
The problem right now is that immutable flow types only support one type definition for each key and value combination.
So immutable.Maps accepts Map<keyType, valueType>
and immutable.List accepts List<valueType>
Immutable.fromJS({ name: 'chet', tags: ['something']})
is equivalent to Map({name: 'chet', tags: List(['something])}
so, your type definition would be
Map<(string) | ('name', 'tags'), string | List<string>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With