fix(striker-ui): add interface for typed EventEmitter

* 'new EventEmitter() as TypedEventEmitter<{ submit: [...args] }>'
main
Tsu-ba-me 2 years ago
parent 0c7c1591ad
commit 558ec9ef67
  1. 21
      striker-ui/types/TypedEventEmitter.d.ts

@ -0,0 +1,21 @@
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;
}
Loading…
Cancel
Save