Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event.currentTarget returns Element and not EventTarget #13383

Closed
DaSchTour opened this issue Jan 10, 2017 · 3 comments
Closed

Event.currentTarget returns Element and not EventTarget #13383

DaSchTour opened this issue Jan 10, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@DaSchTour
Copy link

TypeScript Version: 2.1.4

Code
Example from MDN: https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget

function hide(e){
  e.currentTarget.style.visibility = "hidden";
  // When this function is used as an event handler: this === e.currentTarget
}

var ps = document.getElementsByTagName('p');

for(var i = 0; i < ps.length; i++){
  ps[i].addEventListener('click', hide, false);
}
function hide(e: Event){
  e.currentTarget.style.visibility = "hidden";
  // When this function is used as an event handler: this === e.currentTarget
}

var ps = document.getElementsByTagName('p');

for(var i = 0; i < ps.length; i++){
  ps[i].addEventListener('click', hide, false);
}

Expected behavior:

e.currentTarget should be of type Element or EventTarget should extend Element

Actual behavior:
e.currentTarget is of type EventTarget which only has 3 properties

@FranklinWhale
Copy link

This issue appears to be a duplicate of #299

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label May 24, 2017
@RyanCavanaugh RyanCavanaugh added Duplicate An existing issue was already created and removed Needs Investigation This issue needs a team member to investigate its status. labels Sep 18, 2019
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@ubay1
Copy link

ubay1 commented Apr 1, 2023

work for me

const test = (event: Event) => {
    const eventt = (event.currentTarget as HTMLInputElement);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants