I want to make a tiny system that hold emitter for specific interface like this.
I am using https://github.com/binier/tiny-typed-emitter
Please help me what I am do wrong. Thanks you alot.
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>();
But it print out error
Type 'T' does not satisfy the constraint 'ListenerSignature<T>'.
Type 'IEvenListener' is not assignable to type 'ListenerSignature<T>'.ts(2344)