File tree Expand file tree Collapse file tree 3 files changed +20
-7
lines changed Expand file tree Collapse file tree 3 files changed +20
-7
lines changed Original file line number Diff line number Diff line change
1
+ import { ActionCreator , ActionCreatorsMapObject , Dispatch } from 'redux'
1
2
import bindActionCreators from '../utils/bindActionCreators'
2
3
import { wrapMapToPropsConstant , wrapMapToPropsFunc } from './wrapMapToProps'
3
4
4
- export function whenMapDispatchToPropsIsFunction ( mapDispatchToProps ) {
5
+ export function whenMapDispatchToPropsIsFunction (
6
+ mapDispatchToProps : ActionCreatorsMapObject | ActionCreator < any >
7
+ ) {
5
8
return typeof mapDispatchToProps === 'function'
6
9
? wrapMapToPropsFunc ( mapDispatchToProps , 'mapDispatchToProps' )
7
10
: undefined
8
11
}
9
12
10
- export function whenMapDispatchToPropsIsMissing ( mapDispatchToProps ) {
13
+ export function whenMapDispatchToPropsIsMissing (
14
+ mapDispatchToProps : ActionCreatorsMapObject | ActionCreator < any >
15
+ ) {
11
16
return ! mapDispatchToProps
12
17
? wrapMapToPropsConstant ( ( dispatch ) => ( { dispatch } ) )
13
18
: undefined
14
19
}
15
20
16
- export function whenMapDispatchToPropsIsObject ( mapDispatchToProps ) {
21
+ export function whenMapDispatchToPropsIsObject (
22
+ mapDispatchToProps : ActionCreatorsMapObject | ActionCreator < any >
23
+ ) {
17
24
return mapDispatchToProps && typeof mapDispatchToProps === 'object'
18
- ? wrapMapToPropsConstant ( ( dispatch ) =>
25
+ ? wrapMapToPropsConstant ( ( dispatch : Dispatch ) =>
19
26
bindActionCreators ( mapDispatchToProps , dispatch )
20
27
)
21
28
: undefined
Original file line number Diff line number Diff line change 1
- import { Dispatch } from 'redux'
1
+ import { ActionCreatorsMapObject , Dispatch , ActionCreator } from 'redux'
2
2
3
3
import { FixTypeLater } from '../types'
4
4
import verifyPlainObject from '../utils/verifyPlainObject'
@@ -20,7 +20,13 @@ export function wrapMapToPropsConstant(
20
20
// could be a dispatch function in some cases (ex: whenMapDispatchToPropsIsMissing)
21
21
// and a state object in some others (ex: whenMapStateToPropsIsMissing)
22
22
// eslint-disable-next-line no-unused-vars
23
- getConstant : ( dispatch : Dispatch ) => { dispatch ?: Dispatch }
23
+ getConstant : ( dispatch : Dispatch ) =>
24
+ | {
25
+ dispatch ?: Dispatch
26
+ dependsOnOwnProps ?: boolean
27
+ }
28
+ | ActionCreatorsMapObject
29
+ | ActionCreator < any >
24
30
) {
25
31
return function initConstantSelector ( dispatch : Dispatch ) {
26
32
const constant = getConstant ( dispatch )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ function bindActionCreator<A extends AnyAction = AnyAction>(
17
17
export default function bindActionCreators (
18
18
actionCreators : ActionCreator < any > | ActionCreatorsMapObject ,
19
19
dispatch : Dispatch
20
- ) {
20
+ ) : ActionCreatorsMapObject | ActionCreator < any > {
21
21
if ( typeof actionCreators === 'function' ) {
22
22
return bindActionCreator ( actionCreators , dispatch )
23
23
}
You can’t perform that action at this time.
0 commit comments