@@ -4,25 +4,25 @@ import {
44} from "../../"
55
66declare module "../../" {
7- export interface Dispatch < S > {
8- < R > ( asyncAction : ( dispatch : Dispatch < S > , getState : ( ) => S ) => R ) : R ;
7+ export interface Dispatch < D = Action > {
8+ < R > ( asyncAction : ( dispatch : Dispatch < D > , getState : ( ) => any ) => R ) : R ;
99 }
1010}
1111
12- type Thunk < S , O > = ( dispatch : Dispatch < S > , getState ?: ( ) => S ) => O ;
12+ type Thunk < S , O > = ( dispatch : Dispatch , getState ?: ( ) => S ) => O ;
1313
1414const thunkMiddleware : Middleware =
15- < S > ( { dispatch, getState} : MiddlewareAPI < S > ) =>
16- ( next : Dispatch < S > ) =>
17- < A extends Action , B > ( action : A | Thunk < S , B > ) : B | Action =>
15+ < S , A extends Action > ( { dispatch, getState} : MiddlewareAPI < S > ) =>
16+ ( next : Dispatch < A > ) =>
17+ < B > ( action : A | Thunk < S , B > ) : B | Action =>
1818 typeof action === 'function' ?
1919 ( < Thunk < S , B > > action ) ( dispatch , getState ) :
2020 next ( < A > action )
2121
2222
2323const loggerMiddleware : Middleware =
2424 < S > ( { getState} : MiddlewareAPI < S > ) =>
25- ( next : Dispatch < S > ) =>
25+ ( next : Dispatch ) =>
2626 ( action : any ) : any => {
2727 console . log ( 'will dispatch' , action )
2828
@@ -51,7 +51,7 @@ const storeWithThunkMiddleware = createStore(
5151) ;
5252
5353storeWithThunkMiddleware . dispatch (
54- ( dispatch : Dispatch < State > , getState : ( ) => State ) => {
54+ ( dispatch : Dispatch , getState : ( ) => State ) => {
5555 const todos : string [ ] = getState ( ) . todos ;
5656 dispatch ( { type : 'ADD_TODO' } )
5757 }
0 commit comments