interface IEventKeys { click: String; touchdown: String; } interface IEventKeysMap { click: MouseEvent; touchdown: Event; } class Test { on(event: U, fn: (e: IEventKeysMap[U]) => void) { console.log(event, fn); } } document.addEventListener("touchdown", (e) => { console.log(e); }); const test = new Test(); enum EventKeys { CLICK = "click", TOUCHDOWN = "touchdown", } test.on(EventKeys.CLICK, (args) => { console.log(args); }); test.on(EventKeys.TOUCHDOWN, (args) => { console.log(args); });