2022-07-09 12:40:49 +03:00
|
|
|
import { Composer, Middleware } from 'telegraf';
|
2020-12-23 21:35:40 +03:00
|
|
|
|
2020-12-27 21:35:01 +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
|
|
|
|
2020-12-30 01:49:09 +03:00
|
|
|
export type OnlyFunctionPropertyNames<T> = {
|
2022-08-29 20:21:46 +03:00
|
|
|
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
2020-12-30 01:49:09 +03:00
|
|
|
}[keyof T];
|
|
|
|
|
2022-08-29 20:21:46 +03:00
|
|
|
type ParametersOrNever<T> = T extends (...args: any[]) => any ? Parameters<T> : never;
|
|
|
|
|
2020-12-30 01:49:09 +03:00
|
|
|
export type ComposerMethodArgs<
|
|
|
|
T extends Composer<never>,
|
2022-07-09 12:40:49 +03:00
|
|
|
U extends OnlyFunctionPropertyNames<T> = OnlyFunctionPropertyNames<T>,
|
2022-08-29 20:21:46 +03:00
|
|
|
> = Filter<ParametersOrNever<T[U]>, Middleware<never>>;
|