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)Debería ser
getEmitter<T extends ListenerSignature<T>>