I needed to use useAppDispatch to be able to await on dispatching async thunk actions
interface AppDispatch<A extends Action = AnyAction> {
<T extends A | Function>(action: T): T extends Function ? Promise<AnyAction> : T;
}
function useAppDispatch(): AppDispatch {
return useDispatch();
}
Iam dispatching action as
appDispatch(fetchSocialPagePermissions()).then((pagesResponse) => {
const facebookConnectedPages = pagesResponse?.payload?.facebookPageResponse?.pages;
if (facebookConnectedPages && facebookConnectedPages.length > 0) {
dispatch(exportCollateral({fulfillmentType: FulfillmentType.SHARE_INSTAGRAM}));
}
});
The problem is, there are strict typescript checks, Iam getting this
Don't use `Function` as a type. The `Function` type accepts any function-like value.
It provides no type safety when calling the function, which can be a common source of bugs.
how can a give the type of Function ?