From 8b8005184b0cf799cc963c181c938f385f4209ed Mon Sep 17 00:00:00 2001 From: Donny Verduijn Date: Sat, 12 Oct 2024 19:07:38 +0200 Subject: [PATCH] add deferred type resolution to PropsOf --- .../src/core/factory/create-polymorphic-component.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/@mantine/core/src/core/factory/create-polymorphic-component.ts b/packages/@mantine/core/src/core/factory/create-polymorphic-component.ts index 5bc066e5775..4a8a7ce5c24 100644 --- a/packages/@mantine/core/src/core/factory/create-polymorphic-component.ts +++ b/packages/@mantine/core/src/core/factory/create-polymorphic-component.ts @@ -3,10 +3,9 @@ type ExtendedProps = OverrideProps & type ElementType = keyof JSX.IntrinsicElements | React.JSXElementConstructor; -type PropsOf = JSX.LibraryManagedAttributes< - C, - React.ComponentPropsWithoutRef ->; +type PropsOf = C extends ElementType + ? JSX.LibraryManagedAttributes> + : never; type ComponentProp = { component?: C; @@ -23,7 +22,10 @@ export type PolymorphicComponentProps = C extends React.ElementTy ref?: PolymorphicRef; renderRoot?: (props: any) => any; } - : Props & { component: React.ElementType; renderRoot?: (props: Record) => any }; + : Props & { + component: React.ElementType; + renderRoot?: (props: Record) => any; + }; export function createPolymorphicComponent< ComponentDefaultType,