I have a configured project with React
, Redux
, Immutable.js
+ TypeScript
. During implementation I was trying to declare types as much as possible and found interesting issue. See code example below:
Short configuration of redux store
import { createStore } from 'redux';
import { combineReducers } from 'redux-immutable';
const rootReducer = combineReducers({...});
const store = createStore(rootReducer);
Somewhere inside component
// ...
const mapStateToProps = (state: ReturnType<typeof rootReducer>) => {
// state is plain object :(
};
On state hover in VS Code, tooltip shows that state is a plain object, however it is not. It should be a custom collection from Immutable.js
How can I get a correct type of rootReducer
? Or what I am doing wrong?
Screenshots:
P.S. StateType
and ReturnType
do the same stuff