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

378
Views
TS2339(TS) La propiedad 'toques' no existe en el tipo 'Evento'

Estoy usando VS2019 y TypeScript 4.3.5. El archivo tsconfig.json:

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

apunta a "DOM", es decir, el archivo de declaraciones lib.dom.d.ts que contiene las declaraciones de eventos táctiles. Aquí hay dos (o más):

 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[]; }

Sin embargo, cuando escribo la siguiente línea:

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

Recibo el error: TS2339 (TS) La propiedad 'toques' no existe en el tipo 'Evento'.

Soy bastante nuevo en mecanografiado, ¿alguna idea de lo que estoy haciendo mal?

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

0

Event es el tipo raíz de todos los eventos en window , otros eventos deben heredar ese evento

Por lo tanto, no habrá propiedades de touches dentro del Event en sí, deberá encontrar otros tipos extendidos que tengan propiedades de touches , como TouchEvent

Además, el event es un nombre preservado para la ventana nativa. Evento, intente usar otro nombre para su tipo.

Entonces tu código debería ser como:

 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!