Closed bvaughn closed 5 years ago
Looks like the current set of bridge message we are sending is:
I think we could improve our current Flow definition for the EventEmitter
type to be one that requires explicit event parameters:
declare module "events" {
declare class EventEmitter<Events: Object> {
addListener<Event: $Keys<Events>>(
event: Event,
listener: (...$ElementType<Events, Event>) => any
): void;
emit: <Event: $Keys<Events>>(
event: Event,
...$ElementType<Events, Event>
) => void;
removeListener(event: $Keys<Events>, listener: Function): void;
removeAllListeners(event?: $Keys<Events>): void;
}
declare export default typeof EventEmitter;
}
ea03ddd
It is currently too easy to mismatch types between what we
send
through theBridge
and what we listen for (addListener
). We should harden these types by specifically enumerating all possible combinations.