Conversation
55a2281 to
bc37e0a
Compare
bc37e0a to
08dcdd3
Compare
balloob
commented
Nov 25, 2018
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| "hui-dialog-edit-card": HuiDialogEditCard; | ||
| "hui-dialog-edit-config": HuiDialogEditCard; |
Member
Author
There was a problem hiding this comment.
@bramkragten my fireEvent work found this bug because it verifies that the dialog tag that you try to register is a known element 👍
Member
There was a problem hiding this comment.
edit-card is better than edit-config I think, but good thing you found it.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
I was studying TypeScript tonight and I realized that the way how we register our HTML elements, we can also register events for fireEvent. That gives us this:
Here are some mwah things about this:
undefinedbut TypeScript would still force us to pass inundefinedas 3rd arg, which is lame. So I made detail optional, but that's obviously not always true.polymer-types.ts.fireEventtakesdetailof an event. However, since that's part of CustomEvent, we can't do some typing magic by registering our events in the generic event type map (HTMLElementEventMap). That means that if you want to get the right types going when you typeaddEventListener(…), you need to specify your event a 2nd time.Example: