mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
fix(system-rsc): incorrect typing (#5765)
This commit is contained in:
parent
136bdf66b1
commit
7537226b54
5
.changeset/ten-socks-shave.md
Normal file
5
.changeset/ten-socks-shave.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@heroui/system-rsc": patch
|
||||
---
|
||||
|
||||
fix incorrect typing when using ref (#5753) and as (#5754)
|
||||
@ -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>>
|
||||
>;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user