Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add all EventListener methods to TypedEventEmitter interface #1718

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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