react-uswds icon indicating copy to clipboard operation
react-uswds copied to clipboard

[feat] Export component props

Open brandonlenz opened this issue 2 years ago • 1 comments

Does your feature request relate to a specific USWDS component?

All components, we should make it a convention going forward to export their props

Is your feature request related to a problem? Please describe.

Sometimes consumers want to get TS access to the props our components accept. It's not always easy/intuitive to do so.

Describe the solution you'd like

export all our component prop type definitions, similar to https://github.com/react-bootstrap/react-bootstrap/blob/master/src/index.tsx.

Note: We union our props with IntrinsicElements[THE_ROOT_ELEMENT] pretty often, inline in the component args. We would want those exported with the type, so it might require small refactors to perform the union when declaring the type instead.

Describe alternatives you've considered

The workaround today is for consumers to use ComponentProps, e.g.

type TheProps = ComponentProps<typeof TheReactUswdsComponent>

brandonlenz avatar Sep 14 '23 14:09 brandonlenz

Would #2728 and #2666 together resolve this issue fully?

werdnanoslen avatar Feb 23 '24 16:02 werdnanoslen