There seems to be an issue with my reducers, specifically with the combineReducers function. While it may be something obvious that I am missing, I keep encountering an error.
export default combineReducers<ConfigCategoryState>({
tree: treeReducer(),
});
The error message I receive is as follows:
No overload matches this call.
No overload matches this call.
Overload 1 of 3, '(reducers: ReducersMapObject<ConfigCategoryState, any>): Reducer<CombinedState<ConfigCategoryState>, AnyAction>', gave the following error.
Type 'Reducer<CategoryTree, Action<any>>' is not assignable to type 'Reducer<CategoryTree, any>'.
Types of parameters 'state' and 'state' are incompatible.
Type 'CategoryTree | undefined' is not assignable to type 'CategoryTree'.
Type 'undefined' is not assignable to type 'CategoryTree'.
Overload 2 of 3, '(reducers: ReducersMapObject<ConfigCategoryState, AnyAction>): Reducer<CombinedState<ConfigCategoryState>, AnyAction>', gave the following error.
Type 'Reducer<CategoryTree, Action<any>>' is not assignable to type 'Reducer<CategoryTree, AnyAction>'.
Types of parameters 'state' and 'state' are incompatible.
Type 'CategoryTree | undefined' is not assignable to type 'CategoryTree'.
Type 'undefined' is not assignable to type 'CategoryTree'.ts(2769)
types.ts(35, 3): The expected type comes from property 'tree' which is declared here on type 'ReducersMapObject<ConfigCategoryState, any>'
types.ts(35, 3): The expected type comes from property 'tree' which is declared here on type 'ReducersMapObject<ConfigCategoryState, AnyAction>'
Below is the reducer causing this issue:
const isLoadingReducer = () =>
buildReducer<boolean>(true)
.handle(initCategoryTree, () => false)
.done();
Additionally, here is the corresponding action:
export const initCategoryTree = createAction<CategoryTree, CategoryTree>(
"INIT_CATEGORY_TREE",
(tree) => tree
);
I am unsure if there is anything else missing in my setup. While this error is present in all of my reducers, I have only included one for brevity. I am aware that buildReducer requires a function rather than a function invocation, and removing brackets in combineReducers does not resolve the issue.