@resk/core
Version:
An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla
21 lines (20 loc) • 1.02 kB
TypeScript
/**
* Creates a decorator that can be applied to class properties or methods.
*
* This function takes a key of type KeyType (defaulting to any) and returns a function that takes a value of type ValueType (defaulting to any).
* The returned function is a decorator that can be applied to class properties or methods.
*
* @template KeyType - The type of the key used to store metadata.
* @template ValueType - The type of the value associated with the key.
* @param {KeyType} key - The key under which the metadata will be stored.
* @returns {(value: ValueType) => (target: Object, propertyKey: string) => void} A function that takes a value and returns the decorator function.
* @example
* ```typescript
* const myDecorator = createDecorator('myKey')('myValue');
* class MyClass {
* @myDecorator
* myProperty: string;
* }
* ```
*/
export declare function createDecorator<ValueType = any, KeyType = any>(key: KeyType): (value: ValueType) => (target: Object, propertyKey: string | symbol) => void;