As mentioned, the error only occurs when more than one chat is used for filtering.
Argument of type 'Context & Record<"update", ChatTypeUpdate<"channel" | "group" | "supergroup">> & ChatType<"channel" | "group" | "supergroup"> & Record<...> & ChatFrom<...> & Partial<...> & AliasProps<...>' is not assignable to parameter of type 'ChatTypeContext<Context & Record<"update", ChatTypeUpdate<"channel" | "group" | "supergroup">> & ChatType<"channel" | "group" | "supergroup"> & ChatFrom<...> & Partial<...> & AliasProps<...>, "channel" | ... 1 more ... | "supergroup">'.
// ...
Types of property 'update' are incompatible.
// ...
Types of property 'chat' are incompatible.
Type '(GroupChat & { type: "channel" | "group" | "supergroup"; }) | (SupergroupChat & { type: "channel" | "group" | "supergroup"; })' is not assignable to type '{ type: "supergroup"; }'.
Type 'GroupChat & { type: "channel" | "group" | "supergroup"; }' is not assignable to type '{ type: "supergroup"; }'.
Types of property 'type' are incompatible.
Type '"group"' is not assignable to type '"supergroup"'.ts(2345)
It could be useful to investigate why the two pieces of code are behaving in a different way, as the second version has some use-cases not entirely covered by the first one.
Suppose we have a set of chat types we want to listen for within a middleware, and a handler we need to call on match:
I expect both of the following pieces of code to work properly, but while the first one works fine, the second one shows an error:
As mentioned, the error only occurs when more than one chat is used for filtering.
It could be useful to investigate why the two pieces of code are behaving in a different way, as the second version has some use-cases not entirely covered by the first one.