I want to write a custom event dispatcher supporting a list of different events but i get an type error.


import { EventDispatcher } from "three"

type Test = {
x: number

interface Events {
Test: Test

class CustomDispatcher extends EventDispatcher<Events> {}

const d = new CustomDispatcher()
const test = { x: 1, type: "Test" } as Test

d.dispatchEvent({ type: "Test", x: 1 }) // fine
d.dispatchEvent(test) // error


Argument of type ‘Test’ is not assignable to parameter of type ‘BaseEvent<“Test”> & Test’.
Property ‘type’ is missing in type ‘Test’ but required in type ‘BaseEvent<“Test”>’.ts(2345)
EventDispatcher.d.ts(5, 14): ‘type’ is declared here.

I would like to reuse event objects so i don’t have to create new events on every tick.

New contributor

Quis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.