-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update type definition, Fix test cases
- Loading branch information
Wang Zhongliang
committed
Feb 27, 2018
1 parent
9d5899c
commit b9d9000
Showing
2 changed files
with
38 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
import { Middleware, Dispatch, Action, AnyAction } from "redux"; | ||
import { Middleware, Action, AnyAction } from "redux"; | ||
|
||
|
||
export type ThunkAction<R, S = {}, E = {}, A extends Action<any> = AnyAction> = ( | ||
dispatch: Dispatch<A>, | ||
dispatch: ThunkDispatch<S, E, A>, | ||
getState: () => S, | ||
extraArgument: E | ||
) => R; | ||
|
||
declare module "redux" { | ||
export interface Dispatch<A extends Action<any> = AnyAction> { | ||
<R, E>(asyncAction: ThunkAction<R, {}, E, A>): R; | ||
} | ||
interface ThunkDispatch<S = {}, E = {}, A extends Action = AnyAction> { | ||
<T extends A>(action: T): T; | ||
} | ||
|
||
declare const thunk: Middleware & { | ||
withExtraArgument(extraArgument: any): Middleware; | ||
interface ThunkDispatch<S = {}, E = {}, A extends Action = AnyAction> { | ||
<R>(asyncAction: ThunkAction<R, S, E, A>): R; | ||
} | ||
|
||
type ThunkMiddleware<E, S = {}> = Middleware<ThunkDispatch<S, E>, S, ThunkDispatch<S, E>>; | ||
|
||
declare const thunk: ThunkMiddleware<undefined> & { | ||
withExtraArgument<E>(extraArgument: E): ThunkMiddleware<E> | ||
}; | ||
|
||
export default thunk; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters