1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import * as React from 'react';
|
8 |
|
9 | interface REACT_STATICS {
|
10 | childContextTypes: true;
|
11 | contextType: true;
|
12 | contextTypes: true;
|
13 | defaultProps: true;
|
14 | displayName: true;
|
15 | getDefaultProps: true;
|
16 | getDerivedStateFromError: true;
|
17 | getDerivedStateFromProps: true;
|
18 | mixins: true;
|
19 | propTypes: true;
|
20 | type: true;
|
21 | }
|
22 |
|
23 | interface KNOWN_STATICS {
|
24 | name: true;
|
25 | length: true;
|
26 | prototype: true;
|
27 | caller: true;
|
28 | callee: true;
|
29 | arguments: true;
|
30 | arity: true;
|
31 | }
|
32 |
|
33 | interface MEMO_STATICS {
|
34 | '$$typeof': true;
|
35 | compare: true;
|
36 | defaultProps: true;
|
37 | displayName: true;
|
38 | propTypes: true;
|
39 | type: true;
|
40 | }
|
41 |
|
42 | interface FORWARD_REF_STATICS {
|
43 | '$$typeof': true;
|
44 | render: true;
|
45 | defaultProps: true;
|
46 | displayName: true;
|
47 | propTypes: true;
|
48 | }
|
49 |
|
50 | declare namespace hoistNonReactStatics {
|
51 | type NonReactStatics<
|
52 | S extends React.ComponentType<any>,
|
53 | C extends {
|
54 | [key: string]: true
|
55 | } = {}
|
56 | > = {
|
57 | [key in Exclude<
|
58 | keyof S,
|
59 | S extends React.MemoExoticComponent<any>
|
60 | ? keyof MEMO_STATICS | keyof C
|
61 | : S extends React.ForwardRefExoticComponent<any>
|
62 | ? keyof FORWARD_REF_STATICS | keyof C
|
63 | : keyof REACT_STATICS | keyof KNOWN_STATICS | keyof C
|
64 | >]: S[key]
|
65 | };
|
66 | }
|
67 |
|
68 | declare function hoistNonReactStatics<
|
69 | T extends React.ComponentType<any>,
|
70 | S extends React.ComponentType<any>,
|
71 | C extends {
|
72 | [key: string]: true
|
73 | } = {}
|
74 | >(
|
75 | TargetComponent: T,
|
76 | SourceComponent: S,
|
77 | customStatic?: C,
|
78 | ): T & hoistNonReactStatics.NonReactStatics<S, C>;
|
79 |
|
80 | export = hoistNonReactStatics;
|