forked from quran/quran.com-frontend-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redux-thunk.d.ts
31 lines (29 loc) · 1.04 KB
/
redux-thunk.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// https://github.com/reduxjs/redux-thunk/issues/333
import 'redux';
declare module 'redux' {
/**
* Overload for bindActionCreators redux function, returns expects responses
* from thunk actions
*/
function bindActionCreators<ActionCreators extends ActionCreatorsMapObject<any>>(
actionCreators: ActionCreators,
dispatch: Dispatch,
): {
[ActionCreatorName in keyof ActionCreators]: ReturnType<
ActionCreators[ActionCreatorName]
> extends ThunkAction<any, any, any, any>
? (
...args: Parameters<ActionCreators[ActionCreatorName]>
) => ReturnType<ReturnType<ActionCreators[ActionCreatorName]>>
: ActionCreators[ActionCreatorName];
};
/*
* Overload to add thunk support to Redux's dispatch() function.
* Useful for react-redux or any other library which could use this type.
*/
export interface Dispatch<A extends Action = AnyAction> {
<ReturnType = any, State = any, ExtraThunkArg = any>(
thunkAction: ThunkAction<ReturnType, State, ExtraThunkArg, A>,
): ReturnType;
}
}