-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Closed
Description
If you know how to fix the issue, make a pull request instead.
- I tried using the
@types/nodepackage and had problems. - I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
- I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
- Mention the authors (see
Definitions by:inindex.d.ts) so they can respond.- Authors: @a-tarasyuk @KSXGitHub @mohsen1 @BrunoScheufler (not mentioning more for now)
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
symbolis 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).
G-Rath and BrunoScheufler
Metadata
Metadata
Assignees
Labels
No labels