-
-
Notifications
You must be signed in to change notification settings - Fork 522
Open
Description
Currently the typing events section of the TypeScript documentation just mentions DOM event types and using a this type annotation to control the type of the element associated with the event (which gives a useful type to this but not to event.currentTarget). But now, TargetedEvent and its subtypes are used in the definitions of event types on HTML elements and provide a way to type currentTarget via a type argument. I think the section should be updated and expanded. I'd be happy to do a PR for it. (I may need some guidance, I haven't done any Preact docs stuff before.)
I'm thinking the update would:
- Describe
TargetedEventand its subtypes. - Say that you can continue to use DOM event types if you like.
- Show examples of function components with event handlers not defined inline (and thus not having an inferred type for
event). - Mention that although
TargetedEventis onJSXcurrently, that may change (if it's still true that it may change?). - Explain why
TargetedEventis re-exported bypreact/compat(but its subtypes aren't). (?) - Describe reusing
HTMLAttributeson your own components that wrap DOM elements.
Would a PR along those lines be useful? If so, should it cover anything else?
Metadata
Metadata
Assignees
Labels
No labels