UNPKG

2.05 kBTypeScriptView Raw
1import * as React from 'react';
2import { Omit } from '../_util/types';
3import { WrappedFormInternalProps } from './Form';
4interface REACT_STATICS {
5 childContextTypes: true;
6 contextType: true;
7 contextTypes: true;
8 defaultProps: true;
9 displayName: true;
10 getDefaultProps: true;
11 getDerivedStateFromError: true;
12 getDerivedStateFromProps: true;
13 mixins: true;
14 propTypes: true;
15 type: true;
16}
17interface KNOWN_STATICS {
18 name: true;
19 length: true;
20 prototype: true;
21 caller: true;
22 callee: true;
23 arguments: true;
24 arity: true;
25}
26interface MEMO_STATICS {
27 $$typeof: true;
28 compare: true;
29 defaultProps: true;
30 displayName: true;
31 propTypes: true;
32 type: true;
33}
34interface FORWARD_REF_STATICS {
35 $$typeof: true;
36 render: true;
37 defaultProps: true;
38 displayName: true;
39 propTypes: true;
40}
41declare type NonReactStatics<S extends React.ComponentType<any>, C extends {
42 [key: string]: true;
43} = {}> = {
44 [key in Exclude<keyof S, S extends React.MemoExoticComponent<any> ? keyof MEMO_STATICS | keyof C : S extends React.ForwardRefExoticComponent<any> ? keyof FORWARD_REF_STATICS | keyof C : keyof REACT_STATICS | keyof KNOWN_STATICS | keyof C>]: S[key];
45};
46export declare type Matching<InjectedProps, DecorationTargetProps> = {
47 [P in keyof DecorationTargetProps]: P extends keyof InjectedProps ? InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : InjectedProps[P] : DecorationTargetProps[P];
48};
49export declare type GetProps<C> = C extends React.ComponentType<infer P> ? P : never;
50export declare type ConnectedComponentClass<C extends React.ComponentType<any>, P> = React.ComponentClass<JSX.LibraryManagedAttributes<C, P>> & NonReactStatics<C> & {
51 WrappedComponent: C;
52};
53export declare type FormWrappedProps<TOwnProps extends WrappedFormInternalProps> = <C extends React.ComponentType<Matching<TOwnProps, GetProps<C>>>>(component: C) => ConnectedComponentClass<C, Omit<TOwnProps, keyof WrappedFormInternalProps>>;
54export {};