Skip to content

Update "Typing Events" section to discuss TargetedEvent and subtypes #1098

Open
@tjcrowder

Description

@tjcrowder

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:

  1. Describe TargetedEvent and its subtypes.
  2. Say that you can continue to use DOM event types if you like.
  3. Show examples of function components with event handlers not defined inline (and thus not having an inferred type for event).
  4. Mention that although TargetedEvent is on JSX currently, that may change (if it's still true that it may change?).
  5. Explain why TargetedEvent is re-exported by preact/compat (but its subtypes aren't). (?)
  6. Describe reusing HTMLAttributes on 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy