If you know how to fix the issue, make a pull request instead.
If you do not mention the authors the issue will be ignored.
I was wondering if at some point the definition of EventEmitter should be changed to be more generic eg.
export class EventEmitter<
T extends { [key: string]: any } = { [key: string]: any },
> {
static listenerCount(emitter: EventEmitter, event: string | symbol): number; // deprecated
static defaultMaxListeners: number;
addListener<K extends keyof T>(event: K, listener: (arg: T[K]) => void): this;
...
This would drastically improve type safety for consumers and simplify definitions.
Known issues:
- 2nd degree inheritance cannot easily
symbol is not supported as a generic index type.
- multiple arguments are not possible to be implemented this way eg.
...args
All of these needs to be resolved either by manually declaring the signatures (as done right now) or via declaration merging (also done by some right now).
If you know how to fix the issue, make a pull request instead.
@types/nodepackage and had problems.Definitions by:inindex.d.ts) so they can respond.If you do not mention the authors the issue will be ignored.
I was wondering if at some point the definition of EventEmitter should be changed to be more generic eg.
This would drastically improve type safety for consumers and simplify definitions.
Known issues:
symbolis not supported as a generic index type....argsAll of these needs to be resolved either by manually declaring the signatures (as done right now) or via declaration merging (also done by some right now).