Skip to content

Commit

Permalink
Merge pull request #1855 from reduxjs/feature/v8-typetests
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson authored Dec 22, 2021
2 parents 8622b18 + 0a12648 commit ce83bf8
Show file tree
Hide file tree
Showing 16 changed files with 1,903 additions and 419 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"prepare": "yarn clean && yarn build",
"pretest": "yarn lint",
"test": "jest",
"type-tests": "yarn tsc -p test/typetests",
"type-tests": "yarn tsc -p test/typetests/tsconfig.json",
"coverage": "codecov"
},
"peerDependencies": {
Expand Down
12 changes: 8 additions & 4 deletions src/components/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ import React, { Context, ReactNode, useMemo } from 'react'
import { ReactReduxContext, ReactReduxContextValue } from './Context'
import { createSubscription } from '../utils/Subscription'
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
import type { FixTypeLater } from '../types'
import { Action, AnyAction, Store } from 'redux'

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

function Provider({ store, context, children }: ProviderProps) {
function Provider<A extends Action = AnyAction>({
store,
context,
children,
}: ProviderProps<A>) {
const contextValue = useMemo(() => {
const subscription = createSubscription(store)
return {
Expand All @@ -46,6 +49,7 @@ function Provider({ store, context, children }: ProviderProps) {

const Context = context || ReactReduxContext

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

Expand Down
Loading

0 comments on commit ce83bf8

Please sign in to comment.