From 6ea9cb6eaaf8d0704ff810f0954db885e9ad92f6 Mon Sep 17 00:00:00 2001 From: WK Wong Date: Fri, 3 Oct 2025 21:53:25 +0800 Subject: [PATCH] fix(system-rsc): incorrect typing --- .changeset/ten-socks-shave.md | 5 +++++ .../core/system-rsc/src/extend-variants.d.ts | 20 ++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 .changeset/ten-socks-shave.md diff --git a/.changeset/ten-socks-shave.md b/.changeset/ten-socks-shave.md new file mode 100644 index 0000000000..b2d6003324 --- /dev/null +++ b/.changeset/ten-socks-shave.md @@ -0,0 +1,5 @@ +--- +"@heroui/system-rsc": patch +--- + +fix incorrect typing when using ref (#5753) and as (#5754) diff --git a/packages/core/system-rsc/src/extend-variants.d.ts b/packages/core/system-rsc/src/extend-variants.d.ts index 1f0afe0c38..2dceadae6d 100644 --- a/packages/core/system-rsc/src/extend-variants.d.ts +++ b/packages/core/system-rsc/src/extend-variants.d.ts @@ -3,7 +3,6 @@ import type { ForwardRefExoticComponent, JSXElementConstructor, PropsWithoutRef, - ReactElement, RefAttributes, } from "react"; @@ -78,6 +77,13 @@ export type ExtendVariantWithSlotsProps = { compoundVariants?: Array>>; }; +type InferRef = + C extends ForwardRefExoticComponent> + ? R + : C extends new (...args: any[]) => infer I + ? I + : any; + export type ExtendVariants = { < C extends JSXElementConstructor, @@ -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 : never); - }> & - RefAttributes + PropsWithoutRef< + CP & { + [key in keyof V]?: StringToBoolean; + } + > & + RefAttributes> >; };