UNPKG

1.38 kBTypeScriptView Raw
1import { RuntypeBase } from './runtype';
2declare type PropKey = string | symbol;
3/**
4 * A parameter decorator. Explicitly mark the parameter as checked on every method call in combination with `@checked` method decorator. The number of `@check` params must be the same as the number of provided runtypes into `@checked`.\
5 * Usage:
6 * ```ts
7 * @checked(Runtype1, Runtype3)
8 * method(@check p1: Static1, p2: number, @check p3: Static3) { ... }
9 * ```
10 */
11export declare function check(target: any, propertyKey: PropKey, parameterIndex: number): void;
12/**
13 * A method decorator. Takes runtypes as arguments which correspond to the ones of the actual method.
14 *
15 * Usually, the number of provided runtypes must be _**the same as**_ or _**less than**_ the actual parameters.
16 *
17 * If you explicitly mark which parameter shall be checked using `@check` parameter decorator, the number of `@check` parameters must be _**the same as**_ the runtypes provided into `@checked`.
18 *
19 * Usage:
20 * ```ts
21 * @checked(Runtype1, Runtype2)
22 * method1(param1: Static1, param2: Static2, param3: any) {
23 * ...
24 * }
25 *
26 * @checked(Runtype1, Runtype3)
27 * method2(@check param1: Static1, param2: any, @check param3: Static3) {
28 * ...
29 * }
30 * ```
31 */
32export declare function checked(...runtypes: RuntypeBase[]): (target: any, propertyKey: PropKey, descriptor: PropertyDescriptor) => void;
33export {};