@dolittle/sdk.common
Version:
Dolittle is a decentralized, distributed, event-driven microservice platform built to harness the power of events.
17 lines • 1.68 kB
TypeScript
import { Constructor } from '@dolittle/types';
import { DecoratorTarget } from './DecoratorTarget';
declare type GetMetadataValue<TData> = ((type: Constructor<any>, required?: false, createMetadata?: boolean) => TData | undefined) & ((type: Constructor<any>, required: true, reason: string, createMetadata?: boolean) => TData);
declare type Decorator<TCallback> = (callback: TCallback) => (target: Function | Object, propertyKey?: string | symbol, descriptorOrIndex?: PropertyDescriptor | number) => void;
declare type DecoratorCallback<TData> = (target: DecoratorTarget, type: Constructor<any>, propertyKey: string | symbol | undefined, descriptorOrIndex: PropertyDescriptor | number | undefined, value: TData | undefined) => TData;
/**
* Creates a metadata decorator that is valid for use on the specified targets.
* @param {string} name - The name of the decorator metadata.
* @param {string} displayName - The name of the decorator.
* @param {DecoratorTarget} validTargets - The valid decorator targets.
* @param {boolean} [allowMultipleDecorations] - An optional bool that defines whether the decorator can be applied multiple times, defaults to false.
* @returns {[Decorator<DecoratorCallback>, GetMetadataValue<TData>]} The decorator function, and the function to use to get the stored metadata value returned from the callback.
* @template TData Type of the metadata value.
*/
export declare function createMetadataDecorator<TData>(name: string, displayName: string, validTargets: DecoratorTarget, allowMultipleDecorations?: boolean): [Decorator<DecoratorCallback<TData>>, GetMetadataValue<TData>];
export {};
//# sourceMappingURL=createMetadataDecorator.d.ts.map