@sleekify/sleekify
Version:
A TypeScript decorator driven approach for developing web applications.
61 lines (60 loc) • 2.4 kB
TypeScript
export interface AnnotationOptions {
isInherited?: boolean;
isAdditive?: boolean;
}
type Decorator = (...args: any) => any;
/**
* Gets or sets annotations on a class or class property.
*/
export declare class Annotation {
constructor();
/**
* Indicates whether the annotation exists on the class or property.
* @param target The class
* @param propertyKey The property name
* @param decorator The decorator associated with the annotation
* @returns The annotation's value.
*/
static exists(target: object, propertyKey: string | undefined, decorator: Decorator): boolean;
/**
* Gets the annotation's value.
* @param target The class
* @param propertyKey The property name
* @param decorator The decorator associated with the annotation
* @returns The annotation's value.
*/
static get(target: object, propertyKey: string | undefined, decorator: Decorator): any;
/**
* Finds classes annotated with the decoration by searching files recursively
* under the provided relative path. The classes must be exported as a named
* exports since default exports aren't supported.
*
* @param relativePath The relative file path to search
* @param decorator The decorator applied to the class
*/
static getClassesAnnotatedWith(relativePath: string, decorator: Decorator): Promise<object[]>;
/**
* Every annotation must be registered with a unique key and its annotation options.
*
* @param decorator The decorator being used as an annotation
* @param key The decorator's unique key
* @param options The decorator's options (optional)
*/
static register(decorator: Decorator, key: string, options?: AnnotationOptions): void;
/**
* Sets the annotation's value.
* @param target The class
* @param propertyKey The property name
* @param decorator The decorator being used as an annotation
* @param value The annotation's value
*/
static set(target: object, propertyKey: string | undefined, decorator: Decorator, value?: any): void;
private static getAnnotationMap;
private static getClassKey;
private static getValueForClass;
private static getValueListForClass;
private static getValueForProperty;
private static getValueListForProperty;
private static importClasses;
}
export {};