-
-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make element types more accurate #252
feat: make element types more accurate #252
Conversation
Library consumers may provide any `ElementType` as the `tagName` for the elements created by the library, but the elements themselves were typed as `HTMLDivElement`. The types are widened to the more accurate `HTMLElement`, and some variable names adjusted to reflect the types, e.g. `divElementRef` -> `elementRef`.
This was too wide, allowing for non-HTML element tags like `svg`, which cause runtime errors. Closes bvaughn#251
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Looks like this broke a bunch of things in CI. |
}) { | ||
}): ReactNode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I added keyof HTMLElementTagNameMap
, declaration generation failed despite tsc
being happy. The error message was a red herring - the components just need an explicit return type. Not sure what to make of that.
Maybe just ReactElement
is more appropriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting. Not sure why that is, but I think ReactNode
makes sense as the return type 👍🏼
Was trying to fix the CI issue and missed reverting these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks.
}) { | ||
}): ReactNode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting. Not sure why that is, but I think ReactNode
makes sense as the return type 👍🏼
This widens the usage of
HTMLDivElement
toHTMLElement
throughout.Also narrows the allowed tag names to actual HTML elements. Closes #251