Skip to content
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

Merged
merged 6 commits into from
Dec 31, 2023

Conversation

psychedelicious
Copy link
Contributor

This widens the usage of HTMLDivElement to HTMLElement throughout.

Also narrows the allowed tag names to actual HTML elements. Closes #251

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
Copy link

vercel bot commented Dec 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-resizable-panels ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 30, 2023 11:29pm

@bvaughn
Copy link
Owner

bvaughn commented Dec 30, 2023

Looks like this broke a bunch of things in CI.

Comment on lines -93 to +96
}) {
}): ReactNode {
Copy link
Contributor Author

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?

Copy link
Owner

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.
Copy link
Owner

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks.

Comment on lines -93 to +96
}) {
}): ReactNode {
Copy link
Owner

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 👍🏼

@bvaughn bvaughn merged commit 7db8e09 into bvaughn:main Dec 31, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug (ish): tagName: ElementType is too wide
2 participants