Looking at the code snippet below, I'm struggling to understand why FinalType
is defined as { test: { test_inner: any } }
. The presence of any
is puzzling to me (especially since string
seems to have disappeared). Interestingly, the return type of test
appears correct as { test_inner: string }
.
interface IAction {
type: string;
}
type Reducer<S> = (state: S, action: IAction) => S
function combineReducers<S>(reducers: { [K in keyof S]: Reducer<S[K]> }): Reducer<S> {
const dummy = {} as S;
return () => dummy;
}
const test_inner = (test: string, action: IAction) => {
return 'dummy';
}
const test = combineReducers({
test_inner
});
const test_outer = combineReducers({
test
});
type FinalType = ReturnType<typeof test_outer>;
I'm currently working on typing my redux application, and it seems like the issue isn't specific to redux. While I'm familiar with @types/redux
, I prefer not to use it.