hypothesis / hypothesis/frontend-shared
Consolidate typing for `JSX.HTMLAttributes<...>` in components
- Dominant language
- TypeScript
- Stars
- 8
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
It's generally a Good Thing that our components forward HTML props (i.e. attributes) relevant to the component's outermost elements. This is great for flexibility.
Each component is currently making an ad-hoc decision about which HTML element it should allow props for, and sometimes we have to omit conflicting props (e.g. `size`, `icon`) from the HTML attributes, e.g. At present we have a rather scattershot set of types.
Some questions come to mind:
* Should we aim for narrow or broad in selecting which type of HTML element to accept attributes-as-props for?
In some cases, we're going broad. The `Table` component, as well as most layout components, intersect in `JSX.HTMLAttributes` instead of `HTMLTableElement` and `HTMLDivElement` respectively. Whereas in other places we're narrow: `TableFoot` uses `HTMLTableSectionElement`, `Link` uses `HTMLAnchorElement`.
My gut is that it depends on context, but there should be system here.
* Is there a more systematic way to determine what we should `Omit` from elements' HTML attributes, or is our present strategy (omitting props when we have a type conflict) sufficient? Are there ways we might be accidentally getting ourselves in trouble?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.