Skip to main content

IEventTransformer TypeAlias

This type is a conditional type for transforming all the overloads provided in TEvent.

Signature

export type IEventTransformer<TThis, TEvent extends IEvent> = TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: infer E4, listener: (...args: infer A4) => void): any;
(event: infer E5, listener: (...args: infer A5) => void): any;
(event: infer E6, listener: (...args: infer A6) => void): any;
(event: infer E7, listener: (...args: infer A7) => void): any;
(event: infer E8, listener: (...args: infer A8) => void): any;
(event: infer E9, listener: (...args: infer A9) => void): any;
(event: infer E10, listener: (...args: infer A10) => void): any;
(event: infer E11, listener: (...args: infer A11) => void): any;
(event: infer E12, listener: (...args: infer A12) => void): any;
(event: infer E13, listener: (...args: infer A13) => void): any;
(event: infer E14, listener: (...args: infer A14) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> & TransformedEvent<TThis, E4, A4> & TransformedEvent<TThis, E5, A5> & TransformedEvent<TThis, E6, A6> & TransformedEvent<TThis, E7, A7> & TransformedEvent<TThis, E8, A8> & TransformedEvent<TThis, E9, A9> & TransformedEvent<TThis, E10, A10> & TransformedEvent<TThis, E11, A11> & TransformedEvent<TThis, E12, A12> & TransformedEvent<TThis, E13, A13> & TransformedEvent<TThis, E14, A14> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: infer E4, listener: (...args: infer A4) => void): any;
(event: infer E5, listener: (...args: infer A5) => void): any;
(event: infer E6, listener: (...args: infer A6) => void): any;
(event: infer E7, listener: (...args: infer A7) => void): any;
(event: infer E8, listener: (...args: infer A8) => void): any;
(event: infer E9, listener: (...args: infer A9) => void): any;
(event: infer E10, listener: (...args: infer A10) => void): any;
(event: infer E11, listener: (...args: infer A11) => void): any;
(event: infer E12, listener: (...args: infer A12) => void): any;
(event: infer E13, listener: (...args: infer A13) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> & TransformedEvent<TThis, E4, A4> & TransformedEvent<TThis, E5, A5> & TransformedEvent<TThis, E6, A6> & TransformedEvent<TThis, E7, A7> & TransformedEvent<TThis, E8, A8> & TransformedEvent<TThis, E9, A9> & TransformedEvent<TThis, E10, A10> & TransformedEvent<TThis, E11, A11> & TransformedEvent<TThis, E12, A12> & TransformedEvent<TThis, E13, A13> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: infer E4, listener: (...args: infer A4) => void): any;
(event: infer E5, listener: (...args: infer A5) => void): any;
(event: infer E6, listener: (...args: infer A6) => void): any;
(event: infer E7, listener: (...args: infer A7) => void): any;
(event: infer E8, listener: (...args: infer A8) => void): any;
(event: infer E9, listener: (...args: infer A9) => void): any;
(event: infer E10, listener: (...args: infer A10) => void): any;
(event: infer E11, listener: (...args: infer A11) => void): any;
(event: infer E12, listener: (...args: infer A12) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> & TransformedEvent<TThis, E4, A4> & TransformedEvent<TThis, E5, A5> & TransformedEvent<TThis, E6, A6> & TransformedEvent<TThis, E7, A7> & TransformedEvent<TThis, E8, A8> & TransformedEvent<TThis, E9, A9> & TransformedEvent<TThis, E10, A10> & TransformedEvent<TThis, E11, A11> & TransformedEvent<TThis, E12, A12> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: infer E4, listener: (...args: infer A4) => void): any;
(event: infer E5, listener: (...args: infer A5) => void): any;
(event: infer E6, listener: (...args: infer A6) => void): any;
(event: infer E7, listener: (...args: infer A7) => void): any;
(event: infer E8, listener: (...args: infer A8) => void): any;
(event: infer E9, listener: (...args: infer A9) => void): any;
(event: infer E10, listener: (...args: infer A10) => void): any;
(event: infer E11, listener: (...args: infer A11) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> & TransformedEvent<TThis, E4, A4> & TransformedEvent<TThis, E5, A5> & TransformedEvent<TThis, E6, A6> & TransformedEvent<TThis, E7, A7> & TransformedEvent<TThis, E8, A8> & TransformedEvent<TThis, E9, A9> & TransformedEvent<TThis, E10, A10> & TransformedEvent<TThis, E11, A11> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: infer E4, listener: (...args: infer A4) => void): any;
(event: infer E5, listener: (...args: infer A5) => void): any;
(event: infer E6, listener: (...args: infer A6) => void): any;
(event: infer E7, listener: (...args: infer A7) => void): any;
(event: infer E8, listener: (...args: infer A8) => void): any;
(event: infer E9, listener: (...args: infer A9) => void): any;
(event: infer E10, listener: (...args: infer A10) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> & TransformedEvent<TThis, E4, A4> & TransformedEvent<TThis, E5, A5> & TransformedEvent<TThis, E6, A6> & TransformedEvent<TThis, E7, A7> & TransformedEvent<TThis, E8, A8> & TransformedEvent<TThis, E9, A9> & TransformedEvent<TThis, E10, A10> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: infer E4, listener: (...args: infer A4) => void): any;
(event: infer E5, listener: (...args: infer A5) => void): any;
(event: infer E6, listener: (...args: infer A6) => void): any;
(event: infer E7, listener: (...args: infer A7) => void): any;
(event: infer E8, listener: (...args: infer A8) => void): any;
(event: infer E9, listener: (...args: infer A9) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> & TransformedEvent<TThis, E4, A4> & TransformedEvent<TThis, E5, A5> & TransformedEvent<TThis, E6, A6> & TransformedEvent<TThis, E7, A7> & TransformedEvent<TThis, E8, A8> & TransformedEvent<TThis, E9, A9> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: infer E4, listener: (...args: infer A4) => void): any;
(event: infer E5, listener: (...args: infer A5) => void): any;
(event: infer E6, listener: (...args: infer A6) => void): any;
(event: infer E7, listener: (...args: infer A7) => void): any;
(event: infer E8, listener: (...args: infer A8) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> & TransformedEvent<TThis, E4, A4> & TransformedEvent<TThis, E5, A5> & TransformedEvent<TThis, E6, A6> & TransformedEvent<TThis, E7, A7> & TransformedEvent<TThis, E8, A8> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: infer E4, listener: (...args: infer A4) => void): any;
(event: infer E5, listener: (...args: infer A5) => void): any;
(event: infer E6, listener: (...args: infer A6) => void): any;
(event: infer E7, listener: (...args: infer A7) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> & TransformedEvent<TThis, E4, A4> & TransformedEvent<TThis, E5, A5> & TransformedEvent<TThis, E6, A6> & TransformedEvent<TThis, E7, A7> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: infer E4, listener: (...args: infer A4) => void): any;
(event: infer E5, listener: (...args: infer A5) => void): any;
(event: infer E6, listener: (...args: infer A6) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> & TransformedEvent<TThis, E4, A4> & TransformedEvent<TThis, E5, A5> & TransformedEvent<TThis, E6, A6> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: infer E4, listener: (...args: infer A4) => void): any;
(event: infer E5, listener: (...args: infer A5) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> & TransformedEvent<TThis, E4, A4> & TransformedEvent<TThis, E5, A5> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: infer E4, listener: (...args: infer A4) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> & TransformedEvent<TThis, E4, A4> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: infer E3, listener: (...args: infer A3) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> & TransformedEvent<TThis, E3, A3> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: infer E2, listener: (...args: infer A2) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> & TransformedEvent<TThis, E2, A2> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: infer E1, listener: (...args: infer A1) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> & TransformedEvent<TThis, E1, A1> : TEvent extends {
(event: infer E0, listener: (...args: infer A0) => void): any;
(event: string, listener: (...args: any[]) => void): any;
} ? TransformedEvent<TThis, E0, A0> : TransformedEvent<TThis, string, any[]>;

Type Parameters

Parameter Constraint Description
TThis
TEvent IEvent

Remarks

Due to limitations of the TypeScript typing system, we need to handle each number of overload individually. It currently supports the max of 15 event overloads which is more than we use anywhere. At more than 15 overloads we start to hit TS2589. If we need to move beyond 15 we should evaluate using a mapped type pattern like {"event":(listenerArgs)=>void}