Skip to content

Strict EventTarget #1230

@Richienb

Description

@Richienb

Type description + examples

We would like to have a way to add generics to EventTarget.

const emitter = EventTarget<{
  a: void;
  b: number[];
}>();

means a event with no payload, and b event with number[] payload.

Maybe should actually provide Event object instead as values.

Type source

https://github.com/Richienb/strict-event-target/tree/main

I think it should be some interface extends EventTarget, and we override add/remove - EventListener

TypeScript issue: microsoft/TypeScript#43477

Search existing types and issues first

  • I tried my best to look for it

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions