-
How can we set the correct Typescript type for the context, when using a regex to match a callback query (action)? This works (but does not use regex)
This works (but uses 'any' type)
But 'match' does not exist on Context. What should go in place of 'any'? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Remove the explicit type from ctx. Typescript will infer it. |
Beta Was this translation helpful? Give feedback.
-
Did not know that - that works indeed! In reality though I import a function from another file. I simplified the example in the question thinking it would work the same. This method won't transfer to that scenario, right? The inferred type seems to be |
Beta Was this translation helpful? Give feedback.
You can do that, But the better way is to use Composers to split your bot.
This way you can split your bot into parts without having to do the hard work of typing it correctly yourself. If you have a custom context type, you can pass it to composer like
new Composer<MyCtx>()
as well.