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

types: Move per-element type interfaces into core and more strictly type IntrinsicElements #4546

Merged
merged 11 commits into from
Nov 10, 2024

Conversation

rschristian
Copy link
Member

@rschristian rschristian commented Nov 8, 2024

Closes #4544 and #4202

Someone kindly contributed type interfaces for most elements to compat, so this PR takes those, moves them into core, and alters IntrinsicElements to use those more specific interfaces rather than the massive & generic HTMLAttributes that we used to have. That interface still exists, however, it's been renamed to AllHTMLAttributes, matching React. The new HTMLAttributes is strictly limited to global attributes/props, only the things that are valid & make sense everywhere.

As such, with this PR <div src="/foo.jpg"> will now correctly result in a type error. I'm slightly concerned about breakages because of this but I think it's an unavoidable bandaid we'll have to rip off at some point.

This is a fairly big change and I expect we will have some issues raised. There's 240 or so attributes now spread across a couple dozen interfaces. I've done my best to ensure this is correct but there's a lot of surface area here.

@coveralls
Copy link

coveralls commented Nov 8, 2024

Coverage Status

coverage: 99.488%. remained the same
when pulling 0eefb9b on refactor/intrinsic-elements-and-attributes
into 76d6d4d on main.

@rschristian rschristian force-pushed the refactor/intrinsic-elements-and-attributes branch 2 times, most recently from 94fdf20 to 0e8bee0 Compare November 9, 2024 01:39
@rschristian rschristian changed the title refactor: Create per-element prop/attr interfaces types: Move per-element type interfaces into core and more strictly type IntrinsicElements Nov 9, 2024
@rschristian rschristian force-pushed the refactor/intrinsic-elements-and-attributes branch from 868e5a4 to a450a2f Compare November 9, 2024 02:30
@rschristian rschristian marked this pull request as ready for review November 9, 2024 02:56
@rschristian rschristian linked an issue Nov 9, 2024 that may be closed by this pull request
1 task
Copy link
Member

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

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

WOW, this is amazing

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

This is great!

@rschristian rschristian merged commit 3a95fc1 into main Nov 10, 2024
5 checks passed
@rschristian rschristian deleted the refactor/intrinsic-elements-and-attributes branch November 10, 2024 20:56
@titoBouzout
Copy link

titoBouzout commented Nov 10, 2024

@rschristian Nice, I have updated the table to include the new types
https://potahtml.github.io/namespace-jsx-project/index.html

@rschristian
Copy link
Member Author

Awesome, thanks! Jovi & I were both looking at that, will take another look soon-ish to see which types we're missing (that we do support).

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.

Types: Make per-element types consistent Do these types belong to HTMLAttributes?
5 participants