nestjs-telegraf/lib/types/index.ts
2021-01-02 21:40:13 +03:00

22 lines
698 B
TypeScript

import { BaseScene, Composer, Middleware } from 'telegraf';
export type Filter<T extends any[], F> = T extends []
? []
: T extends [infer Head, ...infer Tail]
? Head extends F
? Filter<Tail, F>
: [Head, ...Filter<Tail, F>]
: [];
export type OnlyFunctionPropertyNames<T> = {
[K in keyof T]: T[K] extends (...args: any) => any ? K : never;
}[keyof T];
export type ComposerMethodArgs<
T extends Composer<never>,
U extends OnlyFunctionPropertyNames<T> = OnlyFunctionPropertyNames<T>
> = Filter<Parameters<T[U]>, Middleware<never>>;
export type UpdateMethods = OnlyFunctionPropertyNames<Composer<never>>;
export type SceneMethods = OnlyFunctionPropertyNames<BaseScene<never>>;