Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use React.JSX instead of JSX for React 19 support #1420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/react/src/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function styled<
>(
componentWithoutStyle: TConstructor & Component<TProps>
): ComponentStyledTagWithoutInterpolation<TConstructor>;
function styled<TName extends keyof JSX.IntrinsicElements>(
function styled<TName extends keyof React.JSX.IntrinsicElements>(
tag: TName
): HtmlStyledTag<TName>;
function styled(
Expand Down Expand Up @@ -244,7 +244,7 @@ export type StyledComponent<T> = WYWEvalMeta &

type StaticPlaceholder = string | number | CSSProperties | WYWEvalMeta;

export type HtmlStyledTag<TName extends keyof JSX.IntrinsicElements> = <
export type HtmlStyledTag<TName extends keyof React.JSX.IntrinsicElements> = <
TAdditionalProps = Record<never, unknown>,
>(
strings: TemplateStringsArray,
Expand All @@ -253,10 +253,10 @@ export type HtmlStyledTag<TName extends keyof JSX.IntrinsicElements> = <
| ((
// Without Omit here TS tries to infer TAdditionalProps
// from a component passed for interpolation
props: JSX.IntrinsicElements[TName] & Omit<TAdditionalProps, never>
props: React.JSX.IntrinsicElements[TName] & Omit<TAdditionalProps, never>
) => string | number)
>
) => StyledComponent<JSX.IntrinsicElements[TName] & TAdditionalProps>;
) => StyledComponent<React.JSX.IntrinsicElements[TName] & TAdditionalProps>;

type ComponentStyledTagWithoutInterpolation<TOrigCmp> = (
strings: TemplateStringsArray,
Expand All @@ -278,14 +278,14 @@ type ComponentStyledTagWithInterpolation<TTrgProps, TOrigCmp> = <OwnProps = {}>(
: StyledComponent<OwnProps & TTrgProps>;

export type StyledJSXIntrinsics = {
readonly [P in keyof JSX.IntrinsicElements]: HtmlStyledTag<P>;
readonly [P in keyof React.JSX.IntrinsicElements]: HtmlStyledTag<P>;
};

export type Styled = typeof styled & StyledJSXIntrinsics;

export default (process.env.NODE_ENV !== 'production'
? new Proxy(styled, {
get(o, prop: keyof JSX.IntrinsicElements) {
get(o, prop: keyof React.JSX.IntrinsicElements) {
return o(prop);
},
})
Expand Down