2

I got TS2339: Property 'target' does not exist on type 'Event'. in below code:

this.$Element.on('click', SELECTOR, (event: JQuery.Event) => {
    const $ClickedLink: JQuery<HTMLElement> = JQuery(event.target);
    //
}

event.currentTarget is also does not exist, as ... defined in JQuery types?

Of course, there are no errors in compiled JavaScript.

This code is not the Angular! I just combine JQuery and class-based OOP.

1 Answer 1

13

This is because the @types/jquery type for the event that is provided to a callback (as opposed to the $.Event function) is called TriggeredEvent, not Event:

this.$Element.on('click', SELECTOR, (event: JQuery.TriggeredEvent) => {
  const $ClickedLink: JQuery<HTMLElement> = JQuery(event.target);
  // ... snip ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.