Skip to content

Export prop types consistently across components (<Name>Props) #877

Description

@ravisuhag

Summary

Roughly half of sampled components don't export their prop type, so consumers can't import and extend it (e.g. to build a typed wrapper). Coverage is inconsistent even among the most-used components.

Current state

Exported: SwitchProps (switch.tsx:19), AccordionRootProps (accordion-root.tsx:27), DialogContentProps (dialog-content.tsx:8), FieldProps (field-root.tsx:9), FieldsetProps (fieldset.tsx:5), IconButtonProps (icon-button.tsx:20), SelectTriggerProps (select-trigger.tsx:36).

Not exported: ButtonProps (button.tsx:127, plain type, no export), CheckboxGroupProps/CheckboxItemProps (checkbox.tsx:61,88, plain interface), TabsRootProps/TabsTabProps (tabs.tsx:25,55).

Native-attribute extension itself is consistent (125 ComponentProps<...> usages across 74 files) — this is purely about the export keyword being missing on the type/interface declaration.

Suggested approach

  • Add export to every <ComponentName>Props type/interface, starting with Button, Checkbox, and Tabs since they're the highest-traffic components.
  • Consider a lint rule (or a codemod + CI check) that flags a component file whose prop type isn't exported, so this doesn't regress on new components.

Notes

Found via a components.build practices audit (types dimension).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestglobalCross-cutting issue affecting multiple components

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions