There seems to be something missing in the type annotations of the _todos-flow_ example, as its combineReducers() function throws a Flow error:
Missing type annotation for
A.Ais a type parameter declared in function type [1] and was implicitly instantiated at call ofcombineReducers[2].
Where the [1] is the type declaration from flow-typed:
declare export function combineReducers<O: Object, A>(reducers: O): CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;
and the [2] the call:
export default combineReducers({
todos,
visibilityFilter
});
So, I inferred that I should type annotate the combineReducers() something like:
export default combineReducers<CombinedReducers, State>
So, the example should instead be something like this, amirite?
import type { State } from '../types';
const reducers = {
todos,
visibilityFilter,
};
export default combineReducers<typeof reducers, State>(reducers);
Or is there something missing in the flow-typed definitions?
I tested using the example project and let the npm and flow-typed just install their things. (I also changed the .flowconfig not to refer to ../../flow-typed, but instead just flow-typed.)
@synchronos-t ran into the same issue. Were you able to resolve this?
I resolved this by
export default combineReducers<Object, Action>(reducers);
Hey @synchronos-t the second type parameter for combineReducers is meant for action instead of state. Check out the libdef for redux in Flow Typed, the file has some more definitions on the top that you can learn about Redux's annotations.
Honestly, I'm inclined to delete the todos-flow example at this point. We don't need like 5 variations of the todos example.
I agree. We don't maintain those types, so it doesn't make sense for us to have an example that uses them.
Most helpful comment
@synchronos-t ran into the same issue. Were you able to resolve this?