fix(dispatcher): improved typings for action filter
This commit is contained in:
parent
f44bf77a07
commit
1238e7c32c
1 changed files with 18 additions and 4 deletions
|
@ -424,13 +424,17 @@ export namespace filters {
|
||||||
ctor === UserStatusUpdate ||
|
ctor === UserStatusUpdate ||
|
||||||
ctor === UserTypingUpdate
|
ctor === UserTypingUpdate
|
||||||
) {
|
) {
|
||||||
const id = (upd as UserStatusUpdate | UserTypingUpdate).userId
|
const id = (upd as UserStatusUpdate | UserTypingUpdate)
|
||||||
return matchSelf && id === upd.client['_userId'] || id in index
|
.userId
|
||||||
|
return (
|
||||||
|
(matchSelf && id === upd.client['_userId']) ||
|
||||||
|
id in index
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
const user = (upd as Exclude<
|
const user = (upd as Exclude<
|
||||||
typeof upd,
|
typeof upd,
|
||||||
Message | UserStatusUpdate | UserTypingUpdate
|
Message | UserStatusUpdate | UserTypingUpdate
|
||||||
>).user
|
>).user
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(matchSelf && user.isSelf) ||
|
(matchSelf && user.isSelf) ||
|
||||||
|
@ -565,7 +569,17 @@ export namespace filters {
|
||||||
type: MaybeArray<T>
|
type: MaybeArray<T>
|
||||||
): UpdateFilter<
|
): UpdateFilter<
|
||||||
Message,
|
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)) {
|
if (Array.isArray(type)) {
|
||||||
const index: Partial<Record<T, true>> = {}
|
const index: Partial<Record<T, true>> = {}
|
||||||
|
|
Loading…
Reference in a new issue