Skip to content

[Replacement]: typed-emitter #885

Description

@43081j

Package to replace

typed-emitter

Suggested replacement(s)

native EventEmitter<T>

Manifest type

native (replaceable by a built-in platform feature)

Rationale

Example from typed-emitter README:

import EventEmitter from "events"
import TypedEmitter from "typed-emitter"

type MessageEvents = {
  error: (error: Error) => void,
  message: (body: string, from: string) => void
};

const messageEmitter = new EventEmitter() as TypedEmitter<MessageEvents>;

This can instead be:

import EventEmitter from "events";

type MessageEvents = {
  error: [error: Error],
  message: [body: string, from: string]
};

const messageEmitter = new EventEmitter<MessageEvents>;

Availability

It was added to @types/node in 2024.

Code example (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions