fix(dispatcher): improved typings for action filter

This commit is contained in:
teidesu 2021-06-19 20:11:06 +03:00
parent f44bf77a07
commit 1238e7c32c

View file

@ -424,8 +424,12 @@ export namespace filters {
ctor === UserStatusUpdate ||
ctor === UserTypingUpdate
) {
const id = (upd as UserStatusUpdate | UserTypingUpdate).userId
return matchSelf && id === upd.client['_userId'] || id in index
const id = (upd as UserStatusUpdate | UserTypingUpdate)
.userId
return (
(matchSelf && id === upd.client['_userId']) ||
id in index
)
} else {
const user = (upd as Exclude<
typeof upd,
@ -565,7 +569,17 @@ export namespace filters {
type: MaybeArray<T>
): UpdateFilter<
Message,
{ action: Extract<MessageAction, { type: T }> }
{
action: Extract<MessageAction, { type: T }>
sender: T extends
| 'user_joined_link'
| 'user_removed'
| 'history_cleared'
| 'contact_joined'
| 'bot_allowed'
? User
: User | Chat
}
> => {
if (Array.isArray(type)) {
const index: Partial<Record<T, true>> = {}