UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

22 lines 1.11 kB
import type { ComponentPropsWithRef, ElementType } from 'react'; /** * Distributive Omit utility type that works correctly with union types */ type DistributiveOmit<T, TOmitted extends PropertyKey> = T extends unknown ? Omit<T, TOmitted> : never; /** * Fixed version of forwardRef that provides better type inference for polymorphic components */ type FixedForwardRef = <T, P = object>(render: (props: P, ref: React.Ref<T>) => React.ReactNode) => (props: P & React.RefAttributes<T>) => React.ReactNode; /** * Cast forwardRef to the fixed version with better type inference */ export declare const fixedForwardRef: FixedForwardRef; /** * Simplified polymorphic props type that handles the common pattern of * `DistributiveOmit<ComponentPropsWithRef<ElementType extends As ? DefaultElement : As>, 'as'>` */ export type PolymorphicProps<TAs extends ElementType, TDefaultElement extends ElementType = 'div', Props = object> = DistributiveOmit<ComponentPropsWithRef<ElementType extends TAs ? TDefaultElement : TAs> & Props, 'as'> & { as?: TAs; }; export {}; //# sourceMappingURL=modern-polymorphic.d.ts.map