I am using combineReducers
in my React TypeScript app:
// combinedReducer.ts
import { combineReducers } from 'redux'
import reducer1 from './reducer1'
import reducer2 from './reducer2'
const combinedReducer = combineReducers({
reducer1,
reducer2,
})
export default combinedReducer
I understand from redux documentation that combineReducers
should infer it's type based on the combined reducers.
However, for me it does not, even though each combined reducer has its return type recognised:
( ReturnType<typeof combidedReducer>
is unknown
)
What is wrong here?
Here are my maximally simplified reducers:
// reducer1.ts
const initialState: boolean = false
const reducer1 = (state = initialState): boolean => state
export default reducer1
// reducer2.ts
const initialState: boolean = false
const reducer2 = (state = initialState): boolean => state
export default reducer2