fix(system-rsc): incorrect typing (#5765)

This commit is contained in:
WK 2025-10-04 10:48:58 +08:00 committed by GitHub
parent 136bdf66b1
commit 7537226b54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 7 deletions

View File

@ -0,0 +1,5 @@
---
"@heroui/system-rsc": patch
---
fix incorrect typing when using ref (#5753) and as (#5754)

View File

@ -3,7 +3,6 @@ import type {
ForwardRefExoticComponent,
JSXElementConstructor,
PropsWithoutRef,
ReactElement,
RefAttributes,
} from "react";
@ -78,6 +77,13 @@ export type ExtendVariantWithSlotsProps = {
compoundVariants?: Array<Record<string, boolean | string | Record<string, string>>>;
};
type InferRef<C> =
C extends ForwardRefExoticComponent<RefAttributes<infer R>>
? R
: C extends new (...args: any[]) => infer I
? I
: any;
export type ExtendVariants = {
<
C extends JSXElementConstructor<any>,
@ -97,12 +103,12 @@ export type ExtendVariants = {
},
opts?: Options,
): ForwardRefExoticComponent<
PropsWithoutRef<{
[key in keyof CP | keyof V]?:
| (key extends keyof CP ? CP[key] : never)
| (key extends keyof V ? StringToBoolean<keyof V[key]> : never);
}> &
RefAttributes<ReactElement>
PropsWithoutRef<
CP & {
[key in keyof V]?: StringToBoolean<keyof V[key]>;
}
> &
RefAttributes<InferRef<C>>
>;
};