Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

377
Views
TS2339(TS) Property 'touches' does not exist on type 'Event'

I'm using VS2019 and TypeScript 4.3.5. The tsconfig.json file:

"compilerOptions": {
    "lib": [ "ES2017.String", "DOM", "ES2020.Intl", "ES2017" ],
    "target": "ES2017"
  }

points to "DOM", i.e. lib.dom.d.ts declarations file containing the touch event declarations. Here are two (of more):

interface Touch {
    readonly altitudeAngle: number;
    readonly azimuthAngle: number;
    readonly clientX: number;
    readonly clientY: number;
    readonly force: number;
    readonly identifier: number;
    readonly pageX: number;
    readonly pageY: number;
    readonly radiusX: number;
    readonly radiusY: number;
    readonly rotationAngle: number;
    readonly screenX: number;
    readonly screenY: number;
    readonly target: EventTarget;
    readonly touchType: TouchType;
}
interface TouchEventInit extends EventModifierInit {
    changedTouches?: Touch[];
    targetTouches?: Touch[];
    touches?: Touch[];
}

Yet, when I write the following line:

const event: Event = window.event;
for (var i = 0; i < event.touches.length; i++);

I get the error: TS2339(TS) Property 'touches' does not exist on type 'Event'.

I'm fairly new to typescript, any ideas what I'm doing wrong?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Event is the root type of all events in window, other events need to inherit that event

So there will be no touches property inside Event itself, you will need to find other extended types that has touches property such as TouchEvent

Also, event is a preserve name for the native window.event, try to use another name for your type.

Then your code should be like:

const customEvent: TouchEvent = window.event;
for (var i = 0; i < customEvent.touches.length; i++);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!