11import logger from '@/lib/logger' ;
22
3- export type DecoratorArgs < T = unknown > = [ T , string , number ] ;
3+ export type DefaultDecoratorArgs = [ unknown ] ;
4+ export type DecoratorArgs <
5+ T extends DefaultDecoratorArgs = DefaultDecoratorArgs ,
6+ > = T extends DefaultDecoratorArgs ? [ string , number ] : T ;
47export type DecoratorFn < TArgs extends DecoratorArgs , TReturn = void > = (
58 ...args : TArgs
69) => TReturn ;
@@ -21,7 +24,11 @@ export type ContextTarget<This, TReturn> = (
2124 * @param descriptorArgs - Arguments for the descriptor function.
2225 * @returns The generated decorator function.
2326 */
24- export function createDecorator < TFnArgs , TArgs = unknown , TReturn = void > (
27+ export function createDecorator <
28+ TFnArgs ,
29+ TArgs extends DefaultDecoratorArgs = DefaultDecoratorArgs ,
30+ TReturn = void ,
31+ > (
2532 descriptorFn : DescriptorFn < TFnArgs , TReturn > ,
2633 descriptorArgs : TFnArgs
2734) : GeneratedDecorator < any > {
@@ -45,7 +52,12 @@ export function createDecorator<TFnArgs, TArgs = unknown, TReturn = void>(
4552 * @param descriptorArgs - Arguments for the descriptor function.
4653 * @returns The generated context-aware decorator.
4754 */
48- export function createContextDecorator < This , TReturn , TFnArgs , TArgs = unknown > (
55+ export function createContextDecorator <
56+ This ,
57+ TReturn ,
58+ TFnArgs ,
59+ TArgs extends DefaultDecoratorArgs = DefaultDecoratorArgs ,
60+ > (
4961 context : ClassMethodDecoratorContext < This , ContextTarget < This , TReturn > > ,
5062 _target : ContextTarget < This , TReturn > ,
5163 descriptorFn : DescriptorFn < TFnArgs , TReturn > ,
0 commit comments