types: Refactor 'AllHTMLAttributes' interface#4706
Merged
rschristian merged 4 commits intomainfrom Feb 26, 2025
Merged
Conversation
rschristian
commented
Feb 24, 2025
rschristian
commented
Feb 24, 2025
| interface DetailsHTMLAttributes<T extends EventTarget = HTMLDetailsElement> | ||
| extends HTMLAttributes<T> { | ||
| open?: Signalish<boolean | undefined>; | ||
| onToggle?: GenericEventHandler<T> | undefined; |
Member
Author
rschristian
commented
Feb 24, 2025
JoviDeCroock
approved these changes
Feb 26, 2025
lukewarlow
reviewed
Feb 26, 2025
| @@ -387,13 +399,15 @@ h('form', { onSubmit: onSubmit }); | |||
|
|
|||
| // Should accept onToggle | |||
| const onToggle = (e: h.JSX.TargetedToggleEvent<HTMLDetailsElement>) => {}; | |||
Contributor
There was a problem hiding this comment.
Shouldn't this be HTMLDialogElement?
Member
Author
There was a problem hiding this comment.
Er yes, yes it should. I think that was a typo.
On the other hand, it does show that our h and createElement types aren't quite correct as they'll accept handlers with generics for other elements than their own. IIUC, the way to fix this is add a h & createElement type definition for every single element.
dc5544e to
61d9e86
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the interest of reducing the maintenance burden of having per-element type interfaces AND the legacy
AllHTMLAttributesinterface, which should theoretically be kept in sync, this converts the latter into an extension of every per-element interface we have.Doing so has caught a few errors already, though there's a limited few properties that have to become
anywhen used from this interface (HTMLInputElement.typevsHTMLAnchorElement.type, for instance).