anvil/striker-ui/types/TypedEventEmitter.d.ts
Tsu-ba-me 558ec9ef67 fix(striker-ui): add interface for typed EventEmitter
* 'new EventEmitter() as TypedEventEmitter<{ submit: [...args] }>'
2022-11-28 14:37:19 -05:00

22 lines
577 B
TypeScript

declare interface TypedEventEmitter<
MapToEventListenerParameters extends Record<string | symbol, unknown[]>,
EventName = keyof MapToEventListenerParameters,
> extends import('events').EventEmitter {
emit(
event: EventName,
...args: MapToEventListenerParameters[EventName]
): boolean;
listenerCount(event: EventName): number;
on(
event: EventName,
listener: (...args: MapToEventListenerParameters[EventName]) => void,
): this;
once(
event: EventName,
listener: (...args: MapToEventListenerParameters[EventName]) => void,
): this;
}