I've been slowly adding Flow type annotations to a small Redux application. However, I'm stuck on adding an annotation for the state in the reducer.
The application in question uses Immutable.js, and the state parameter is an instance of Immutable.Map
. Try as I might, I can't figure out how to annotate that.
Here is the reducer in question:
// @flow
import {List, Map, fromJS} from 'immutable';
type Action = {
type: string,
content: mixed
};
export default function(state = Map(), action: Action) {
switch (action.type) {
case 'ADD_LINK': {
let links = state.get('links').push(fromJS(action.content));
return state.set('links', links);
}
case 'UPDATE_FILTER':
return state.set('filter', fromJS(action.content));
default:
return state;
}
}
Any idea how I can add a type annotation for the state as an Immutable.js map? I've tried the following without success, and now I'm stumped:
import type { Map } from 'immutable';
export default function (state: Map = Map(), action: Action) {