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

205
Views
type myEventHandler<T extends myEvent> = (event: T) => void;

Soy nuevo en mecanografiar.

¿Se pregunta qué significa exactamente esta línea en TS?:

 type myEventHandler<T extends myEvent> = (event: T) => void;

Sé que <> es una afirmación de tipo. Así que supongo que myEventHandler debería ser el tipo de T. Pero 'myEventHandler' también es un tipo, ¿verdad? Entonces, ¿eso significa que podemos definir un tipo que pertenece a otro tipo? Supongo que el evento: T es un parámetro, ¿entonces un tipo también puede tener un parámetro? Esta línea parece una función de flecha gorda... y tiene un vacío. ¿Alguien puede explicarlo?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

En este caso, <T extends myEvent> no es una aserción de tipo. Más bien declara el tipo como genérico . Ahora puede pasar argumentos de cualquier tipo T , siempre que el tipo extends myEvent .

Debe leer la introducción de TypeScript a Genéricos para obtener más referencias.

about 4 years ago · Santiago Gelvez 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!