nestjs-telegraf/lib/types/index.ts

22 lines
700 B
TypeScript
Raw Normal View History

2021-01-02 15:47:17 +03:00
import { BaseScene, Composer, Middleware } from 'telegraf';
2020-12-23 21:35:40 +03:00
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>]
: [];
2020-12-25 23:57:17 +03:00
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>>;
2021-01-03 16:11:17 +03:00
export type ComposerMethods = OnlyFunctionPropertyNames<Composer<never>>;
export type SceneMethods = OnlyFunctionPropertyNames<BaseScene<never>>;