Skip to content

Commit ce83bf8

Browse files
authored
Merge pull request #1855 from reduxjs/feature/v8-typetests
2 parents 8622b18 + 0a12648 commit ce83bf8

16 files changed

+1903
-419
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"prepare": "yarn clean && yarn build",
3737
"pretest": "yarn lint",
3838
"test": "jest",
39-
"type-tests": "yarn tsc -p test/typetests",
39+
"type-tests": "yarn tsc -p test/typetests/tsconfig.json",
4040
"coverage": "codecov"
4141
},
4242
"peerDependencies": {

src/components/Provider.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@ import React, { Context, ReactNode, useMemo } from 'react'
22
import { ReactReduxContext, ReactReduxContextValue } from './Context'
33
import { createSubscription } from '../utils/Subscription'
44
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
5-
import type { FixTypeLater } from '../types'
65
import { Action, AnyAction, Store } from 'redux'
76

87
export interface ProviderProps<A extends Action = AnyAction> {
98
/**
109
* The single Redux store in your application.
1110
*/
12-
store: Store<FixTypeLater, A>
11+
store: Store<any, A>
1312
/**
1413
* Optional context to be used internally in react-redux. Use React.createContext() to create a context to be used.
1514
* If this is used, you'll need to customize `connect` by supplying the same context provided to the Provider.
1615
* Initial value doesn't matter, as it is overwritten with the internal state of Provider.
1716
*/
18-
context?: Context<ReactReduxContextValue>
17+
context?: Context<ReactReduxContextValue<any, A>>
1918
children: ReactNode
2019
}
2120

22-
function Provider({ store, context, children }: ProviderProps) {
21+
function Provider<A extends Action = AnyAction>({
22+
store,
23+
context,
24+
children,
25+
}: ProviderProps<A>) {
2326
const contextValue = useMemo(() => {
2427
const subscription = createSubscription(store)
2528
return {
@@ -46,6 +49,7 @@ function Provider({ store, context, children }: ProviderProps) {
4649

4750
const Context = context || ReactReduxContext
4851

52+
// @ts-ignore 'AnyAction' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype
4953
return <Context.Provider value={contextValue}>{children}</Context.Provider>
5054
}
5155

0 commit comments

Comments
 (0)