Creating TypeSafe event emitter wrapper function
I have this file
EventTypes.ts
:
And I'm trying to create a wrapper function emitBotEvent()
What I'm trying to do is, if I put BUEvents.BanListImport
, the 2nd parameter of emitBotEvent()
function should expect the type [payload: BanImportOptions]
And if I put BUEvents.BotGuildBanAdd
, the type shuold become [ban: GuildBan, executor: GuildMember]
I tried the above way, it doesn't work 1 Reply
I think I got resonable amount of type safety with this: