import type { CssFunction } from '../types'; type WithConditionalCSSProp = 'className' extends keyof TProps ? string extends TProps['className' & keyof TProps] ? { /** * ## CSS prop * * Style a JSX element. * For further details [read the API documentation](https://compiledcssinjs.com/docs/api-css-prop). * * ### Style with objects * * @example * ``` * import { css } from '@compiled/react'; * *
* ``` * * ### Style with template literals * * @example * ``` * import { css } from '@compiled/react'; * *
* ``` * * ### Compose styles with arrays * * @example * ``` * import { css } from '@compiled/react'; * *
* ``` */ css?: CssFunction | CssFunction[]; } : // eslint-disable-next-line @typescript-eslint/ban-types {} : // eslint-disable-next-line @typescript-eslint/ban-types {}; // Unpack all here to avoid infinite self-referencing when defining our own JSX namespace // Based on the code from @types/react@18.2.8 / @emotion-js // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3197efc097d522c4bf02b94e1a0766d007d6cdeb/types/react/index.d.ts#LL3204C13-L3204C13 type ReactJSXElementType = string | React.JSXElementConstructor; type ReactJSXElement = JSX.Element; type ReactJSXElementClass = JSX.ElementClass; type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty; type ReactJSXElementChildrenAttribute = JSX.ElementChildrenAttribute; type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes; type ReactJSXIntrinsicClassAttributes = JSX.IntrinsicClassAttributes; type ReactJSXIntrinsicElements = JSX.IntrinsicElements; export namespace CompiledJSX { export type ElementType = ReactJSXElementType; export type Element = ReactJSXElement; export type ElementClass = ReactJSXElementClass; export type ElementAttributesProperty = ReactJSXElementAttributesProperty; export type ElementChildrenAttribute = ReactJSXElementChildrenAttribute; // In React 18's @types/react, ReactManagedAttributes delegated to GlobalJSXLibraryManagedAttributes // which aliased back to JSX.LibraryManagedAttributes. When CompiledJSX is used as the JSX namespace // that created a circular reference through our own definition. React 19's @types/react removed that // indirection, breaking the old code. We avoid the issue entirely by not delegating to // ReactJSXLibraryManagedAttributes and instead intersecting P with { key?: React.Key } directly. // eslint-disable-next-line @typescript-eslint/no-unused-vars export type LibraryManagedAttributes<_C, P> = WithConditionalCSSProp

& P & { key?: React.Key }; export type IntrinsicAttributes = ReactJSXIntrinsicAttributes; export type IntrinsicClassAttributes = ReactJSXIntrinsicClassAttributes; export type IntrinsicElements = { [K in keyof ReactJSXIntrinsicElements]: Omit & { // We override class name so we can pass xcss prop to it. We opt to do this instead of // Making the output of cssMap() a string intersection so we can also have an inline object // be declared. /** * The class name prop now can be given the output of xcss prop from `@compiled/react`. */ className?: string | Record | null | false; css?: CssFunction | CssFunction[]; }; }; }