@@ -2,25 +2,81 @@ import 'react'
22import { Interpolation } from '@emotion/serialize'
33import { Theme } from '@emotion/react'
44
5+ type IsPreReact19 = 2 extends Parameters < React . FunctionComponent < any > > [ 'length' ]
6+ ? true
7+ : false
8+
59type WithConditionalCSSProp < P > = 'className' extends keyof P
610 ? string extends P [ 'className' & keyof P ]
711 ? { css ?: Interpolation < Theme > }
812 : { }
913 : { }
1014
11- // unpack all here to avoid infinite self-referencing when defining our own JSX namespace
12- type ReactJSXElement = JSX . Element
13- type ReactJSXElementClass = JSX . ElementClass
14- type ReactJSXElementAttributesProperty = JSX . ElementAttributesProperty
15- type ReactJSXElementChildrenAttribute = JSX . ElementChildrenAttribute
16- type ReactJSXLibraryManagedAttributes < C , P > = JSX . LibraryManagedAttributes < C , P >
17- type ReactJSXIntrinsicAttributes = JSX . IntrinsicAttributes
18- type ReactJSXIntrinsicClassAttributes < T > = JSX . IntrinsicClassAttributes < T >
19- type ReactJSXIntrinsicElements = JSX . IntrinsicElements
20-
21- // based on the code from @types /[email protected] 22- // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3197efc097d522c4bf02b94e1a0766d007d6cdeb/types/react/index.d.ts#LL3204C13-L3204C13
23- type ReactJSXElementType = string | React . JSXElementConstructor < any >
15+ // unpack all here to avoid infinite self-referencing when defining our own JSX namespace for the pre-React 19 case
16+ type ReactJSXElement = true extends IsPreReact19
17+ ? /** @ts -ignore */
18+ JSX . Element
19+ : /** @ts -ignore */
20+ React . JSX . Element
21+ type ReactJSXElementClass = true extends IsPreReact19
22+ ? /** @ts -ignore */
23+ JSX . ElementClass
24+ : /** @ts -ignore */
25+ React . JSX . ElementClass
26+ type ReactJSXElementAttributesProperty = true extends IsPreReact19
27+ ? /** @ts -ignore */
28+ JSX . ElementAttributesProperty
29+ : /** @ts -ignore */
30+ React . JSX . ElementAttributesProperty
31+ type ReactJSXElementChildrenAttribute = true extends IsPreReact19
32+ ? /** @ts -ignore */
33+ JSX . ElementChildrenAttribute
34+ : /** @ts -ignore */
35+ React . JSX . ElementChildrenAttribute
36+ type ReactJSXLibraryManagedAttributes < C , P > = true extends IsPreReact19
37+ ? /** @ts -ignore */
38+ JSX . LibraryManagedAttributes < C , P >
39+ : /** @ts -ignore */
40+ React . JSX . LibraryManagedAttributes < C , P >
41+ type ReactJSXIntrinsicAttributes = true extends IsPreReact19
42+ ? /** @ts -ignore */
43+ JSX . IntrinsicAttributes
44+ : /** @ts -ignore */
45+ React . JSX . IntrinsicAttributes
46+ type ReactJSXIntrinsicClassAttributes < T > = true extends IsPreReact19
47+ ? /** @ts -ignore */
48+ JSX . IntrinsicClassAttributes < T >
49+ : /** @ts -ignore */
50+ React . JSX . IntrinsicClassAttributes < T >
51+ type ReactJSXIntrinsicElements = true extends IsPreReact19
52+ ? /** @ts -ignore */
53+ JSX . IntrinsicElements
54+ : /** @ts -ignore */
55+ React . JSX . IntrinsicElements
56+
57+ type ReactJSXElementType = true extends IsPreReact19
58+ ?
// based on the code from @types /[email protected] 59+ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3197efc097d522c4bf02b94e1a0766d007d6cdeb/types/react/index.d.ts#LL3204C13-L3204C13
60+ string | React . JSXElementConstructor < any >
61+ : /** @ts -ignore */
62+ React . JSX . ElementType
63+
64+ export namespace ReactJSX {
65+ type ElementType = ReactJSXElementType
66+ interface Element extends ReactJSXElement { }
67+ interface ElementClass extends ReactJSXElementClass { }
68+ interface ElementAttributesProperty
69+ extends ReactJSXElementAttributesProperty { }
70+ interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute { }
71+
72+ type LibraryManagedAttributes < C , P > = ReactJSXLibraryManagedAttributes < C , P >
73+
74+ interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes { }
75+ interface IntrinsicClassAttributes < T >
76+ extends ReactJSXIntrinsicClassAttributes < T > { }
77+
78+ type IntrinsicElements = ReactJSXIntrinsicElements
79+ }
2480
2581export namespace EmotionJSX {
2682 type ElementType = ReactJSXElementType
0 commit comments