File tree 3 files changed +6
-5
lines changed
3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ export function combineReducers<S>(reducers: ReducersMapObject): Reducer<S>;
94
94
* before passing them to the next middleware.
95
95
*/
96
96
export interface Dispatch < S > {
97
- ( action : Action ) : Action ;
97
+ < A extends Action > ( action : A ) : A ;
98
98
}
99
99
100
100
/**
@@ -267,7 +267,7 @@ export interface MiddlewareAPI<S> {
267
267
* asynchronous API call into a series of synchronous actions.
268
268
*/
269
269
export interface Middleware {
270
- < S > ( api : MiddlewareAPI < S > ) : ( next : Dispatch < S > ) => any ;
270
+ < S > ( api : MiddlewareAPI < S > ) : ( next : Dispatch < S > ) => Dispatch < S > ;
271
271
}
272
272
273
273
/**
Original file line number Diff line number Diff line change @@ -15,15 +15,15 @@ const addTodo: ActionCreator<AddTodoAction> = (text: string) => ({
15
15
16
16
const addTodoAction : AddTodoAction = addTodo ( 'test' ) ;
17
17
18
- type AddTodoThunk = ( dispatch : Dispatch ) => AddTodoAction ;
18
+ type AddTodoThunk = ( dispatch : Dispatch < any > ) => AddTodoAction ;
19
19
20
20
const addTodoViaThunk : ActionCreator < AddTodoThunk > = ( text : string ) =>
21
- ( dispatch : Dispatch ) => ( {
21
+ ( dispatch : Dispatch < any > ) => ( {
22
22
type : 'ADD_TODO' ,
23
23
text
24
24
} )
25
25
26
- declare const dispatch : Dispatch ;
26
+ declare const dispatch : Dispatch < any > ;
27
27
28
28
const boundAddTodo = bindActionCreators ( addTodo , dispatch ) ;
29
29
Original file line number Diff line number Diff line change @@ -13,3 +13,4 @@ declare module "../../index.d.ts" {
13
13
}
14
14
15
15
const dispatchThunkResult : number = dispatch ( ( ) => 42 ) ;
16
+ const dispatchedTimerId : number = dispatch ( d => setTimeout ( ( ) => d ( { type : 'TYPE' } ) , 1000 ) ) ;
You can’t perform that action at this time.
0 commit comments