-
-
Notifications
You must be signed in to change notification settings - Fork 432
/
redux-thunk.d.ts
32 lines (30 loc) · 1.09 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
32
// https://github.com/reduxjs/redux-thunk/issues/333
import 'redux';
declare module 'redux' {
// eslint-disable-next-line jsdoc/require-returns
/**
* 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;
}
}