Closed anilanar closed 5 years ago
Actually, even if we had the type I propose above, it wouldn't make the reducer extend from one that allows AnyAction
argument; again due to contravariance.
I guess all functions/types that work with deox reducers need to know about all action types too, inconvenient but necessary.
A reducer created with
createReducer
can be called with any action that has a (string?)type
property. However,createReducer
limits its action argument to those that are specifically handled by it.Due to contravariance,
(state: State, action: SpecificActions) => State
does not extend(state: State, action: AnyAction) => State
.I know why
createReducer
is typed in such a way, but I wonder if some conditional type magic can allow us to encode handled action types + any action except those that are handled?