Skip to content

React.SyntheticEvent has wrong interface #10811

Closed

Description

@huan086

Type definitions for React v0.14

The SyntheticEvent has the signature

    interface SyntheticEvent<T> {
        ...
        currentTarget: EventTarget;
        ....
        target: EventTarget & T;
        ...
    }

which is incorrect. event.target is the HTMLElement that is being clicked on, while event.currentTarget is where handlers has been set. It is impossible for one to know the target (what is clicked on) at compile time, thus specifying T makes no sense. The HTMLElement where I attached events is known at compile time, thus T can be specified for currentTarget

See https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget

Activity

  1. alitaheri commented on Sep 7, 2016

    @alitaheri
    Contributor

    Seems like this can be closed as it was fixed in #10784 and released as @types/react v0.14.34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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