1- function bindActionCreator ( actionCreator , dispatch ) {
2- return function ( ) {
3- return dispatch ( actionCreator . apply ( this , arguments ) )
1+ import { AnyAction , ActionCreator , Dispatch , ActionCreatorsMapObject } from '..'
2+
3+ function bindActionCreator < A extends AnyAction = AnyAction > (
4+ actionCreator : ActionCreator < A > ,
5+ dispatch : Dispatch
6+ ) {
7+ return function ( this : any , ...args : any [ ] ) {
8+ return dispatch ( actionCreator . apply ( this , args ) )
49 }
510}
611
@@ -13,19 +18,22 @@ function bindActionCreator(actionCreator, dispatch) {
1318 * For convenience, you can also pass an action creator as the first argument,
1419 * and get a dispatch wrapped function in return.
1520 *
16- * @param { Function|Object } actionCreators An object whose values are action
21+ * @param actionCreators An object whose values are action
1722 * creator functions. One handy way to obtain it is to use ES6 `import * as`
1823 * syntax. You may also pass a single function.
1924 *
20- * @param { Function } dispatch The `dispatch` function available on your Redux
25+ * @param dispatch The `dispatch` function available on your Redux
2126 * store.
2227 *
23- * @returns { Function|Object } The object mimicking the original object, but with
28+ * @returns The object mimicking the original object, but with
2429 * every action creator wrapped into the `dispatch` call. If you passed a
2530 * function as `actionCreators`, the return value will also be a single
2631 * function.
2732 */
28- export default function bindActionCreators ( actionCreators , dispatch ) {
33+ export default function bindActionCreators (
34+ actionCreators : ActionCreator < any > | ActionCreatorsMapObject ,
35+ dispatch : Dispatch
36+ ) {
2937 if ( typeof actionCreators === 'function' ) {
3038 return bindActionCreator ( actionCreators , dispatch )
3139 }
@@ -39,7 +47,7 @@ export default function bindActionCreators(actionCreators, dispatch) {
3947 )
4048 }
4149
42- const boundActionCreators = { }
50+ const boundActionCreators : ActionCreatorsMapObject = { }
4351 for ( const key in actionCreators ) {
4452 const actionCreator = actionCreators [ key ]
4553 if ( typeof actionCreator === 'function' ) {
0 commit comments