@@ -13,54 +13,53 @@ type WithConditionalCSSProp<P> = 'className' extends keyof P
13
13
: { }
14
14
15
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
16
+
17
+ // the IsPreReact19 and @ts -ignore comments are to allow @emotion/react to support three different cases of types
18
+ // - pre-React 18.something which didn't have `React.JSX`
19
+ // - React 18.something with `React.JSX`
20
+ // - React 19 with `React.JSX` and no global `JSX`
21
+ // we support both pre-React 19 cases by using the global `JSX` and with the React 19 types, we use `React.JSX`
22
+ // to make this work, we need @ts-ignore comments to ignore references that are invalid
23
+ // though note that the error types resulting from ignoring the errors will never be used
24
+ // since the pre vs post React 19 conditional will pick the one that won't error
25
+
26
+ // prettier-ignore
27
+ /** @ts -ignore */
28
+ type ReactJSXElement = true extends IsPreReact19 ? JSX . Element : React . JSX . Element
29
+
30
+ // prettier-ignore
31
+ /** @ts -ignore */
32
+ type ReactJSXElementClass = true extends IsPreReact19 ? JSX . ElementClass : React . JSX . ElementClass
33
+
34
+ // prettier-ignore
35
+ /** @ts -ignore */
36
+ type ReactJSXElementAttributesProperty = true extends IsPreReact19 ? JSX . ElementAttributesProperty : React . JSX . ElementAttributesProperty
37
+
38
+ // prettier-ignore
39
+ /** @ts -ignore */
40
+ type ReactJSXElementChildrenAttribute = true extends IsPreReact19 ? JSX . ElementChildrenAttribute : React . JSX . ElementChildrenAttribute
41
+
42
+ // prettier-ignore
43
+ /** @ts -ignore */
44
+ type ReactJSXLibraryManagedAttributes < C , P > = true extends IsPreReact19 ? JSX . LibraryManagedAttributes < C , P > : React . JSX . LibraryManagedAttributes < C , P >
45
+
46
+ // prettier-ignore
47
+ /** @ts -ignore */
48
+ type ReactJSXIntrinsicAttributes = true extends IsPreReact19 ? JSX . IntrinsicAttributes : React . JSX . IntrinsicAttributes
49
+
50
+ // prettier-ignore
51
+ /** @ts -ignore */
52
+ type ReactJSXIntrinsicClassAttributes < T > = true extends IsPreReact19 ? JSX . IntrinsicClassAttributes < T > : React . JSX . IntrinsicClassAttributes < T >
53
+
54
+ // prettier-ignore
55
+ /** @ts -ignore */
56
+ type ReactJSXIntrinsicElements = true extends IsPreReact19 ? JSX . IntrinsicElements : React . JSX . IntrinsicElements
56
57
57
58
// based on the code from @types /[email protected]
58
59
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3197efc097d522c4bf02b94e1a0766d007d6cdeb/types/react/index.d.ts#LL3204C13-L3204C13
60
+ // prettier-ignore
59
61
/** @ts -ignore */
60
- type ReactJSXElementType = true extends IsPreReact19
61
- ? string | React . JSXElementConstructor < any >
62
- : /** @ts -ignore */
63
- React . JSX . ElementType
62
+ type ReactJSXElementType = true extends IsPreReact19 ? string | React . JSXElementConstructor < any > : React . JSX . ElementType
64
63
65
64
export namespace ReactJSX {
66
65
export type ElementType = ReactJSXElementType
0 commit comments