radix-ui / primitives

Radix Primitives is an open-source UI component library for building high-quality, accessible design systems and web apps. Maintained by @workos.
https://radix-ui.com/primitives
MIT License
14.94k stars 730 forks source link

Not getting proper typing on Popper types in Popover #2895

Open JonathanLorimer opened 2 months ago

JonathanLorimer commented 2 months ago

Question

When I check out the types of PopperContentProps in my editor I see this:

type PopperContentProps = Radix.ComponentPropsWithoutRef<any>

which is giving me any on all the popover props I care about.

However if I go to definition I see this chain:

// go to defintion of PoperContentProps
type PopperContentProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;
// go to definition of Popper.Primitive.Content
export const Content: React.ForwardRefExoticComponent<PopperContentProps & React.RefAttributes<HTMLDivElement>>;
// go to definition of PopperContentProps
export interface PopperContentProps extends PrimitiveDivProps {
    side?: Side;
    sideOffset?: number;
    align?: Align;
    alignOffset?: number;
    arrowPadding?: number;
    avoidCollisions?: boolean;
    collisionBoundary?: Boundary | Boundary[];
    collisionPadding?: number | Partial<Record<Side, number>>;
    sticky?: 'partial' | 'always';
    hideWhenDetached?: boolean;
    updatePositionStrategy?: 'optimized' | 'always';
    onPlaced?: () => void;
}

The go to definition seems to be what I want, not sure why I am getting any in my LSP, I wonder if the name collision between PoperContentProps is causing an infinite loop?

JonathanLorimer commented 2 months ago

May be related to use of typescript 5^ and react 18^, see related issue https://github.com/radix-ui/primitives/issues/2309