Typescript gives an error, since the poll event is not defined.
No overload matches this call.
The last overload gave the following error.
Argument of type '"poll"' is not assignable to parameter of type '"polling_error" | "webhook_error" | "error"'.
The listener is being called on poll answers, therefore only the types are affected.
Steps to reproduce the Behavior
Create a bot instance: const bot = new TelegramBot(token, { polling: true });.
Subscribe to poll event:
bot.on('poll', () => {
// do something here
});
Here's all the definitions for on fn from the lib's d.ts file:
I have read:
I am using the latest version of the library (
0.63.0
).Expected Behavior
When using
bot.on('poll', listener)
, there is no typescript error. This event is listed here: https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#eventsActual Behavior
Typescript gives an error, since the
poll
event is not defined.The listener is being called on poll answers, therefore only the types are affected.
Steps to reproduce the Behavior
const bot = new TelegramBot(token, { polling: true });
.poll
event:Here's all the definitions for
on
fn from the lib's d.ts file:Spoiler
```ts on( event: TelegramBot.MessageType | 'message', listener: (message: TelegramBot.Message, metadata: TelegramBot.Metadata) => void, ): this; on(event: 'callback_query', listener: (query: TelegramBot.CallbackQuery) => void): this; on(event: 'inline_query', listener: (query: TelegramBot.InlineQuery) => void): this; on(event: 'poll_answer', listener: (answer: TelegramBot.PollAnswer) => void): this; on(event: 'chat_member' | 'my_chat_member', listener: (member: TelegramBot.ChatMemberUpdated) => void): this; on(event: 'chosen_inline_result', listener: (result: TelegramBot.ChosenInlineResult) => void): this; on( event: | 'channel_post' | 'edited_message' | 'edited_message_text' | 'edited_message_caption' | 'edited_channel_post' | 'edited_channel_post_text' | 'edited_channel_post_caption', listener: (message: TelegramBot.Message) => void, ): this; on(event: 'shipping_query', listener: (query: TelegramBot.ShippingQuery) => void): this; on(event: 'pre_checkout_query', listener: (query: TelegramBot.PreCheckoutQuery) => void): this; on(event: 'polling_error' | 'webhook_error' | 'error', listener: (error: Error) => void): this; on(event: 'chat_join_request', listener: (query: TelegramBot.ChatJoinRequest) => void): this; ```