/
ClassDecoratorFunction.d.ts
32 lines (31 loc) · 1.11 KB
/
ClassDecoratorFunction.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* eslint-disable @typescript-eslint/no-explicit-any */
import type {
Class
} from "type-fest";
/**
* A class decorator which does returns a class to replace the class it receives.
*
* @typeParam BaseClassType - the user's class type. Usually `typeof UserClass`.
* @typeParam ReturnsModified - the modified class type, true for returning the base class, or false for returning void.
* @typeParam Arguments - require arguments to execute the decorator.
* @param baseClass - the user's class.
* @param context - the decorator context from the JavaScript engine.
*
* @see {@link https://github.com/tc39/proposal-decorators#classes}
*/
export type ClassDecoratorFunction<
BaseClassType extends Class<object>,
ReturnsModified extends boolean | BaseClassType,
Arguments extends any[] | false
> = (
Arguments extends any[] ?
(...args: Arguments) => ClassDecoratorFunction<BaseClassType, ReturnsModified, false> :
(
baseClass: BaseClassType,
context: ClassDecoratorContext,
) => (
ReturnsModified extends BaseClassType ? ReturnsModified :
true extends ReturnsModified ? BaseClassType :
void
)
);