Description
Do you want to request a feature or report a bug?
Minor Bug in typescript definitions
What is the current behavior?
When using typescript and combineReducers, the preloadedState parameter is forced to contain the full/entire initial state for every reducer. This is because the typescript definition for the preloadedState parameter is "S
" instead of "Partial<S>
".
What is the expected behavior?
From the redux documentation: http://redux.js.org/docs/recipes/reducers/InitializingState.html
With combineReducers() the behavior is more nuanced. Those reducers whose state is specified in preloadedState will receive that state. Other reducers will receive undefined and because of that will fall back to the state = ... default argument they specify.
In general, preloadedState wins over the state specified by the reducer. This lets reducers specify initial data that makes sense to them as default arguments, but also allows loading existing data (fully or partially) when you're hydrating the store from some persistent storage or the server.
The current typescript definition does not allow supplying state for only some reducers.
Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?
All versions using typescript and the preloadedState parameter to createStore as far as I can see.