I encountered this error in TypeScript while I was doing some drag and drop functionality. I had to find the ClassName of the component that was dragged so I thought of finding it via:

// event: Event

The error below was my destiny:

error TS2339: Property 'includes' does not exist on type 'EventTarget'

and in the console:

ERROR TypeError: event.target.includes is not a function


The error comes from Typescript not being totally sure about what event: Event holds inside. This can be a lot of things ( AnimationEventChangeEvent, ...). 

In this case, it is an Element.

Element is the most general base class from which all element objects (i.e. objects that represent elements) in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element. For example, the HTMLElement interface is the base interface for HTML elements, while the SVGElement interface is the basis for all SVG elements. Most functionality is specified further down the class hierarchy.

So we just set the type and we're good.

    const target = event.target as Element;
    if ((target.className).includes('my-component')) {
    .... // logic



Saved you some valuable time?

Buy me a drink 🍺