UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

16 lines (15 loc) 757 B
import { ComponentPropsWithRef, ElementType } from "react"; //#region src/utils/modern-polymorphic.d.ts /** * Distributive Omit utility type that works correctly with union types */ type DistributiveOmit<T, TOmitted extends PropertyKey> = T extends unknown ? Omit<T, TOmitted> : never; /** * Simplified polymorphic props type that handles the common pattern of * `DistributiveOmit<ComponentPropsWithRef<ElementType extends As ? DefaultElement : As>, 'as'>` */ type PolymorphicProps<TAs extends ElementType, TDefaultElement extends ElementType = 'div', Props = object> = DistributiveOmit<ComponentPropsWithRef<ElementType extends TAs ? TDefaultElement : TAs> & Props, 'as'> & { as?: TAs; }; //#endregion export { DistributiveOmit, PolymorphicProps };