-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Hi, thanks for the great library 👍
I have a question about the subclasses with different events example that you provided in the readme:
The example works when calling the events from outside the class, but not from within the class itself. Specifically, if I alter the example to be as follows:
class Animal<E extends ListenerSignature<E> = ListenerSignature<unknown>> extends TypedEmitter<{ spawn: () => void } & E> {
public constructor() {
super();
}
private doSpawn() {
this.emit('spawn');
}
}
class Frog<E extends ListenerSignature<E>> extends Animal<{ jump: (testing: boolean) => void } & E> {}
class Bird<E extends ListenerSignature<E>> extends Animal<{ fly: () => void } & E> {}
Then the compiler fails at the this.emit('spawn');
line with the error: Argument of type '[]' is not assignable to parameter of type 'Parameters<({ spawn: () => void; } & E)["spawn"]>'.
I'm assuming this is because of some constraint that can't be applied, but I can't seem to wrap my head around it. Is there any way to solve this?
jacobbubu, scottpageindysoft, lenovouser, ShockTr, amrlly and 3 more
Metadata
Metadata
Assignees
Labels
No labels