I am currently working on implementing an event bus and have organized all event names and parameters in one interface. Here is how it looks:
interface A {
a: {
x: number
y: number
}
b: {
name: string
}
}
function on<T extends keyof A>(evName: T, cb: (ev, param: A[T]) => void) {}
Writing the callback function like this works fine:
on('a', (ev, param) => {})
When trying to write the callback function in another file as shown below:
// file 1
on('a', doA)
// file 2
export const doA: (ev, params: ?) = (ev, params) => {}
I am unsure of how to declare the type for the doA()
function.