错误本身:
(alias) deleteCategory(id: number): (dispatch: Dispatch<AnyAction>) => void
import deleteCategory
Argument of type '(dispatch: Dispatch) => void' is not assignable to parameter of type 'AnyAction'.
Property 'type' is missing in type '(dispatch: Dispatch) => void' but required in type 'AnyAction'.ts(2345)
Run Code Online (Sandbox Code Playgroud)
有问题的代码:
export function getCategoryList(
categories: CategoryType[],
dispatch: Dispatch
) {
return categories.map((category: CategoryType) => ({
...category,
onDelete: () => {
dispatch(deleteCategory(category._id)); //FIXME: Fix this. Error Appears here
},
}));
}
Run Code Online (Sandbox Code Playgroud)
删除类别的实现:
export const deleteCategory = (id: number) => (dispatch: Dispatch) …
Run Code Online (Sandbox Code Playgroud)