1 | import { ComponentType, NamedExoticComponent } from 'react';
|
2 | import { NonReactStatics } from 'hoist-non-react-statics';
|
3 | /**
|
4 | * This interface can be augmented by users to add default types for the root state when
|
5 | * using `react-redux`.
|
6 | * Use module augmentation to append your own type definition in a your_custom_type.d.ts file.
|
7 | * https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
|
8 | */
|
9 | export interface DefaultRootState {
|
10 | }
|
11 | export interface Store<S = {}> {
|
12 | setState: (state: Partial<S>) => void;
|
13 | getState: () => S;
|
14 | subscribe: (listener: () => void) => () => void;
|
15 | }
|
16 | export interface StoreProp<S = {}> {
|
17 | store: Store<S>;
|
18 | }
|
19 | /**
|
20 | * A property P will be present if:
|
21 | * - it is present in DecorationTargetProps
|
22 | *
|
23 | * Its value will be dependent on the following conditions
|
24 | * - if property P is present in InjectedProps and its definition extends the definition
|
25 | * in DecorationTargetProps, then its definition will be that of DecorationTargetProps[P]
|
26 | * - if property P is not present in InjectedProps then its definition will be that of
|
27 | * DecorationTargetProps[P]
|
28 | * - if property P is present in InjectedProps but does not extend the
|
29 | * DecorationTargetProps[P] definition, its definition will be that of InjectedProps[P]
|
30 | */
|
31 | export declare type Matching<InjectedProps, DecorationTargetProps> = {
|
32 | [P in keyof DecorationTargetProps]: P extends keyof InjectedProps ? InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : InjectedProps[P] : DecorationTargetProps[P];
|
33 | };
|
34 | /**
|
35 | * a property P will be present if :
|
36 | * - it is present in both DecorationTargetProps and InjectedProps
|
37 | * - InjectedProps[P] can satisfy DecorationTargetProps[P]
|
38 | * ie: decorated component can accept more types than decorator is injecting
|
39 | *
|
40 | * For decoration, inject props or ownProps are all optionally
|
41 | * required by the decorated (right hand side) component.
|
42 | * But any property required by the decorated component must be satisfied by the injected property.
|
43 | */
|
44 | export declare type Shared<InjectedProps, DecorationTargetProps> = {
|
45 | [P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;
|
46 | };
|
47 | export declare type GetProps<C> = C extends ComponentType<infer P> ? P : never;
|
48 | export declare type ConnectedComponent<C extends ComponentType<any>, T, P> = NamedExoticComponent<JSX.LibraryManagedAttributes<C, Omit<GetProps<C>, keyof Shared<T, GetProps<C>>> & P>> & NonReactStatics<C> & {
|
49 | WrappedComponent: C;
|
50 | };
|