EdJoPaTo / grammy-inline-menu

Inline Menus for Telegram made simple. Successor of telegraf-inline-menu.
MIT License
354 stars 46 forks source link

More useful Telegraf Context TypeScript Typings #17

Closed EdJoPaTo closed 4 years ago

EdJoPaTo commented 5 years ago

Currently I often use (ctx: any) as something likectx.session or ctx.match is missing and then gets highlighted by the TypeScript compiler.

I thought about adding a generic to the class itself so it would look like this:

const menu = new TelegrafInlineMenu<MyContextType>(ctx => `Hey ${ctx.from.first_name}!`)
menu.simpleButton('I am excited!', 'a', {
  doFunc: ctx => ctx.reply(ctx.session.something)
})

But I am not sure what the best way would be here. Any ideas anyone?

(ctx.match should be added to the Telegraf typings itself, something like ctx.session should not, as its a user variable)

EdJoPaTo commented 4 years ago

This is included in the upcoming version 5