type AsProp = { as?: T; }; export type PolymorphicRef = React.ComponentPropsWithRef['ref']; export type PolymorphicProps< T extends React.ElementType, Props = Record > = AsProp & React.ComponentPropsWithoutRef & Props & { ref?: PolymorphicRef; }; export type PolymorphicComponent> = (< TT extends React.ElementType = T >( props: PolymorphicProps ) => React.ReactNode) & { displayName?: string; };