Skip to content

Commit

Permalink
fix: add all EventListener methods to TypedEventEmitter interface (
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Oct 20, 2023
1 parent 4296ad6 commit b96882a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/lib/TypedEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ export interface TypedEventEmitter<
event: TEvent,
callback: TEvents[TEvent],
): this
prependListener<TEvent extends keyof TEvents>(
event: TEvent,
callback: TEvents[TEvent],
): this
prependOnceListener<TEvent extends keyof TEvents>(
event: TEvent,
callback: TEvents[TEvent],
): this

removeListener<TEvent extends keyof TEvents>(
event: TEvent,
callback: TEvents[TEvent],
Expand All @@ -28,12 +37,29 @@ export interface TypedEventEmitter<
event: TEvent,
callback: TEvents[TEvent],
): this

removeAllListeners(event?: keyof TEvents): this

emit<TEvent extends keyof TEvents>(
event: TEvent,
...args: Parameters<TEvents[TEvent]>
): boolean

setMaxListeners(n: number): this
getMaxListeners(): number

listeners<TEvent extends keyof TEvents>(
eventName: TEvent,
): TEvents[TEvent][]
rawListeners<TEvent extends keyof TEvents>(
eventName: TEvent,
): TEvents[TEvent][]
listenerCount<TEvent extends keyof TEvents>(
event: TEvent,
listener?: TEvents[TEvent],
): number

eventNames(): Array<keyof TEvents>
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
Expand Down

0 comments on commit b96882a

Please sign in to comment.