Strictly typed definitions for
EventTarget
Only used for type-checking; compiles to no code.
npm install strict-event-target
import type StrictEventTarget from 'strict-event-target';
const target = new (EventTarget as typeof StrictEventTarget<{
foo: string; // Event with data
}, [
'bar', // Event without data
]>);
target.dispatchEvent(new CustomEvent('foo', {detail: 'The'}));
target.dispatchEvent(new Event('bar'));
import type StrictEventTarget from 'strict-event-target';
class Foo extends (EventTarget as typeof StrictEventTarget<{
foo: string; // Event with data
}, [
'bar', // Event without data
]>) {}
Type: Record<string, unknown>
Default: {}
Events that will be created with CustomEvent
, thus being able to contain custom data.
Type: string[]
Default: []
Events that will be created with Event
.