Skip to main content

Listeners TypeAlias

Used to specify the kinds of events emitted by a Listenable.

Signature

export type Listeners<T extends object> = {
[P in (string | symbol) & keyof T as IsListener<T[P]> extends true ? P : never]: T[P];
};

Type Parameters

Parameter Constraint Description
T object

Remarks

Any object type is a valid Listeners, but only the event-like properties of that type will be included.

Example

interface MyEvents {
load: (user: string, data: IUserData) => void;
error: (errorCode: number) => void;
}