import { Context, createContext } from 'react'; type ObjectOfFunctions = { [key: string]: (...args: any[]) => void; }; export type EventContext = T extends ObjectOfFunctions ? T : never; export const createEventContext = (): Context< EventContext > => createContext>({} as EventContext);