import { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType, PropsWithChildren } from 'react'; export type AsProp = { as?: C; }; type PropsToOmit = keyof (AsProp & P); export type PolymorphicComponentProp< C extends ElementType, Props = {} > = PropsWithChildren> & Omit, PropsToOmit>; export type PolymorphicRef< C extends ElementType > = ComponentPropsWithRef['ref']; export type PolymorphicComponentPropWithRef< C extends ElementType, Props = {} > = PolymorphicComponentProp & { ref?: PolymorphicRef } & { displayName?: string; };