Reputation: 923
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.
Upvotes: 2
Views: 1386
Reputation: 159895
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 ...
}
Upvotes: 13