UNPKG

624 BTypeScriptView Raw
1import { Middleware, Action, AnyAction } from "redux";
2
3export interface ThunkDispatch<S, E, A extends Action> {
4 <T extends A>(action: T): T;
5 <R>(asyncAction: ThunkAction<R, S, E, A>): R;
6}
7
8export type ThunkAction<R, S, E, A extends Action> = (
9 dispatch: ThunkDispatch<S, E, A>,
10 getState: () => S,
11 extraArgument: E
12) => R;
13
14export type ThunkMiddleware<S = {}, A extends Action = AnyAction, E = undefined> = Middleware<ThunkDispatch<S, E, A>, S, ThunkDispatch<S, E, A>>;
15
16declare const thunk: ThunkMiddleware & {
17 withExtraArgument<E>(extraArgument: E): ThunkMiddleware<{}, AnyAction, E>
18}
19
20export default thunk;