Skip to content

Commit 7c2b73f

Browse files
committed
Fix types issues with context props
1 parent e729165 commit 7c2b73f

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
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() {

test/hooks/useDispatch.spec.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ describe('React', () => {
2727
})
2828
describe('createDispatchHook', () => {
2929
it("returns the correct store's dispatch function", () => {
30-
const nestedContext =
31-
React.createContext<ReactReduxContextValue | null>(null)
30+
const nestedContext = React.createContext<ReactReduxContextValue>(
31+
null as any
32+
)
3233
const useCustomDispatch = createDispatchHook(nestedContext)
3334
const { result } = renderHook(() => useDispatch(), {
3435
// eslint-disable-next-line react/prop-types

test/hooks/useSelector.spec.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,9 @@ describe('React', () => {
697697
})
698698

699699
it('subscribes to the correct store', () => {
700-
const nestedContext =
701-
React.createContext<ReactReduxContextValue | null>(null)
700+
const nestedContext = React.createContext<ReactReduxContextValue>(
701+
null as any
702+
)
702703
const useCustomSelector = createSelectorHook(nestedContext)
703704
let defaultCount = null
704705
let customCount = null

0 commit comments

Comments
 (0)