Skip to content

Commit 8ec5802

Browse files
committed
Fix types issues with context props
1 parent e729165 commit 8ec5802

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/components/Provider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface ProviderProps<A extends Action = AnyAction> {
1515
* If this is used, you'll need to customize `connect` by supplying the same context provided to the Provider.
1616
* Initial value doesn't matter, as it is overwritten with the internal state of Provider.
1717
*/
18-
context?: Context<ReactReduxContextValue | null>
18+
context?: Context<ReactReduxContextValue>
1919
children: ReactNode
2020
}
2121

src/components/connect.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,9 @@ function connect<
425425
TMergedProps = {},
426426
State = DefaultRootState
427427
>(
428-
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>,
429-
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
430-
mergeProps: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>,
428+
mapStateToProps?: MapStateToPropsParam<TStateProps, TOwnProps, State>,
429+
mapDispatchToProps?: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
430+
mergeProps?: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>,
431431
options?: ConnectOptions<State, TStateProps, TOwnProps, TMergedProps>
432432
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps & ConnectProps>
433433

test/components/connect.spec.tsx

+9-10
Original file line numberDiff line numberDiff line change
@@ -2154,10 +2154,9 @@ describe('React', () => {
21542154
}
21552155
}
21562156

2157-
const context = React.createContext<ReactReduxContextValue<
2158-
any,
2159-
AnyAction
2160-
> | null>(null)
2157+
const context = React.createContext<
2158+
ReactReduxContextValue<any, AnyAction>
2159+
>(null as any)
21612160

21622161
let actualState
21632162

@@ -2196,10 +2195,9 @@ describe('React', () => {
21962195
}
21972196
}
21982197

2199-
const context = React.createContext<ReactReduxContextValue<
2200-
any,
2201-
AnyAction
2202-
> | null>(null)
2198+
const context = React.createContext<
2199+
ReactReduxContextValue<any, AnyAction>
2200+
>(null as any)
22032201

22042202
let actualState
22052203

@@ -2451,8 +2449,9 @@ describe('React', () => {
24512449
(state: RootStateType = 0, action: ActionType) =>
24522450
action.type === 'INC' ? state + 1 : state
24532451
)
2454-
const customContext =
2455-
React.createContext<ReactReduxContextValue | null>(null)
2452+
const customContext = React.createContext<ReactReduxContextValue>(
2453+
null as any
2454+
)
24562455

24572456
class A extends Component {
24582457
render() {

0 commit comments

Comments
 (0)