!feat(): use dynamic types for listener decorators

This commit is contained in:
unknown
2020-12-27 21:35:01 +03:00
parent 16969365f2
commit b3dc258c70
28 changed files with 97 additions and 270 deletions

View File

@@ -0,0 +1,15 @@
import { SetMetadata } from '@nestjs/common';
import { UpdateMethodArgs, UpdateMethods } from '../telegraf.types';
import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
import { ListenerMetadata } from '../interfaces/listener-metadata.interface';
export function createUpdateDecorator<Method extends UpdateMethods>(
method: Method,
) {
return (...args: UpdateMethodArgs<Method>): MethodDecorator => {
return SetMetadata(UPDATE_LISTENER_METADATA, {
method,
args,
} as ListenerMetadata);
};
}