-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
Currently, all of the rhea interfaces that extend EventEmitter
do not provide an EventMap
generic argument, so event handlers do not have strong typings.
For example,
import { create_container } from 'rhea';
const container = create_container();
container.on('message', function (context) {
// context is any and has no intellisense or type safety
});
If a generic event map argument is supplied to EventEmitter
when extending it, we can get type safety and intellisense on all of the declared events, e.g.
// container.d.ts
type ContainerEvents = {
'message': [EventContext]
// add all container events here
};
interface Container extends EventEmitter<ContainerEvents> {
// ...
}
This will give developers intellisense on event names when registering handlers to the EventEmitter
s and provide typings on the callback arguments.
foster-hangdaan
Metadata
Metadata
Assignees
Labels
No labels