Type Alias TypedEventEmitter<T>

TypedEventEmitter: Record<string, unknown> & _BaseTypedEventEmitter<
    T & _BuiltInEvents<T>,
>

A type-checked EventEmitter.

Type Parameters

  • T extends EventListeners = Record<never, never>

    The event names and listener signatures

import { EventEmitter } from 'events';

type Events = {
success: () => void;
error: (error: Error) => void;
};

class TypedClass extends (EventEmitter as new () => TypedEventEmitter<Events>) {}

Typed EventEmitter