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

243
Views
¿Cómo puedo hacer una función genérica con el retorno TypedEmitter<T>?

Quiero hacer un pequeño sistema que contenga un emisor para una interfaz específica como esta.

Estoy usando https://github.com/binier/tiny-typed-emitter

Por favor, ayúdame en lo que estoy haciendo mal. Muchas gracias.

 interface IEvenListener { } interface IPlayerJoinedListener extends IEvenListener { onPlayerJoined: (playerId: string) => void; } let emitter: TypedEmitter = ...; function getEmitter<T extends IEvenListener>(): TypedEmitter<T> // error here { return emitter as TypedEmitter<T>; } const messageEmitter = getEmitter<IPlayerJoinedListener>();

Pero imprime error

 Type 'T' does not satisfy the constraint 'ListenerSignature<T>'. Type 'IEvenListener' is not assignable to type 'ListenerSignature<T>'.ts(2344)
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Debería ser

 getEmitter<T extends ListenerSignature<T>>
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!