Skip to content

Popover: Expose TypeScript types for subcomponents #69615

@mirka

Description

@mirka

The subcomponents of the Popover component are not exposing their TypeScript types, for example as we can witness here:

{ /* @ts-expect-error Slot is not currently typed on Popover */ }
<Popover.Slot name={ SLOT_NAME } />

This is due to how the component is put together and exported:

// @ts-expect-error For Legacy Reasons
Popover.Slot = forwardRef( PopoverSlot );
// @ts-expect-error For Legacy Reasons
Popover.__unstableSlotNameProvider = slotNameContext.Provider;
export default Popover;

As we can see demonstrated in the Menu component, there are ways to expose the types correctly with dot-notation subcomponents. When done correctly, the subcomponents can also be documented in the Storybook props tables, as we can see in the one for Menu.

There is also some more information in the Naming Conventions section of the Contributing Guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions