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