@@ -4,25 +4,25 @@ import {
4
4
} from "../../"
5
5
6
6
declare 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 ;
9
9
}
10
10
}
11
11
12
- type Thunk < S , O > = ( dispatch : Dispatch < S > , getState ?: ( ) => S ) => O ;
12
+ type Thunk < S , O > = ( dispatch : Dispatch , getState ?: ( ) => S ) => O ;
13
13
14
14
const 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 =>
18
18
typeof action === 'function' ?
19
19
( < Thunk < S , B > > action ) ( dispatch , getState ) :
20
20
next ( < A > action )
21
21
22
22
23
23
const loggerMiddleware : Middleware =
24
24
< S > ( { getState} : MiddlewareAPI < S > ) =>
25
- ( next : Dispatch < S > ) =>
25
+ ( next : Dispatch ) =>
26
26
( action : any ) : any => {
27
27
console . log ( 'will dispatch' , action )
28
28
@@ -51,7 +51,7 @@ const storeWithThunkMiddleware = createStore(
51
51
) ;
52
52
53
53
storeWithThunkMiddleware . dispatch (
54
- ( dispatch : Dispatch < State > , getState : ( ) => State ) => {
54
+ ( dispatch : Dispatch , getState : ( ) => State ) => {
55
55
const todos : string [ ] = getState ( ) . todos ;
56
56
dispatch ( { type : 'ADD_TODO' } )
57
57
}
0 commit comments