From a767c5576dbcb86c629d080cb419adbda04e6f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Frank?= Date: Wed, 19 Dec 2018 13:58:45 +0100 Subject: [PATCH] added context prop to provider + exposed ReactReduxContext from react-redux. --- types/react-redux/index.d.ts | 43 +++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index bcbcced0bd..1a62ed6b56 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -31,7 +31,8 @@ import { Component, ComponentClass, ComponentType, - StatelessComponent + StatelessComponent, + Context } from 'react'; import { @@ -66,10 +67,10 @@ export type AdvancedComponentDecorator = */ export type Matching = { [P in keyof DecorationTargetProps]: P extends keyof InjectedProps - ? InjectedProps[P] extends DecorationTargetProps[P] - ? DecorationTargetProps[P] - : InjectedProps[P] - : DecorationTargetProps[P]; + ? InjectedProps[P] extends DecorationTargetProps[P] + ? DecorationTargetProps[P] + : InjectedProps[P] + : DecorationTargetProps[P]; }; /** @@ -114,22 +115,22 @@ export type InferableComponentEnhancer = export type InferThunkActionCreatorType any> = TActionCreator extends (...args: infer TParams) => (...args: any[]) => infer TReturn - ? (...args: TParams) => TReturn - : TActionCreator; + ? (...args: TParams) => TReturn + : TActionCreator; export type HandleThunkActionCreator = TActionCreator extends (...args: any[]) => any - ? InferThunkActionCreatorType - : TActionCreator; + ? InferThunkActionCreatorType + : TActionCreator; // redux-thunk middleware returns thunk's return value from dispatch call // https://github.com/reduxjs/redux-thunk#composition export type ResolveThunks = TDispatchProps extends { [key: string]: any } - ? { - [C in keyof TDispatchProps]: HandleThunkActionCreator - } - : TDispatchProps; + ? { + [C in keyof TDispatchProps]: HandleThunkActionCreator + } + : TDispatchProps; /** * Connects a React component to a Redux store. @@ -390,11 +391,21 @@ export interface ConnectOptions { withRef?: boolean; } +export interface ReactReduxContextType { + store: Store; + storeState: SS; +} + export interface ProviderProps { /** * The single Redux store in your application. */ store: Store; + /** + * Optional context to be used internally in react-redux. Initial value doesn't matter, as it is overwritten with the + * internal state of Provider. + */ + context?: Context>; } /** @@ -410,3 +421,9 @@ export class Provider extends Component;