@typescript-package/wrapped-descriptor
Version:
A lightweight TypeScript library for wrapped property descriptor.
92 lines (91 loc) • 3.59 kB
TypeScript
import { WrappedDescriptorCore } from './wrapped-descriptor-core.abstract';
import { WrappedPropertyDescriptor } from '@typedly/descriptor';
import { SetterCallback, GetterCallback } from '@typedly/callback';
/**
* @description The base abstraction class for plain wrapped descriptors.
* @export
* @abstract
* @class PlainWrappedDescriptorBase
* @template [O=any] The type of the object to define the descriptor on.
* @template {keyof O} [K=keyof O] The key of the object to define the descriptor on.
* @template {K extends keyof O ? O[K] : any} [V=K extends keyof O ? O[K] : any] The value type of the key in the object.
* @template {boolean} [A=boolean] The type of active.
* @template {boolean} [N=boolean] The type of enabled.
* @template {boolean} [C=boolean] The type of configurable.
* @template {boolean} [E=boolean] The type of enumerable.
* @template {PlainWrappedDescriptorBase<O, K, V, A, N, C, E, D> | PropertyDescriptor} [D=PlainWrappedDescriptorBase<O, K, V, A, N, C, E, any>]
* @extends {WrappedDescriptorCore<O, K, V, A, N, C, E, D>}
*/
export declare abstract class PlainWrappedDescriptorBase<O = any, K extends keyof O = keyof O, V extends K extends keyof O ? O[K] : any = K extends keyof O ? O[K] : any, A extends boolean = boolean, N extends boolean = boolean, C extends boolean = boolean, E extends boolean = boolean, D extends PlainWrappedDescriptorBase<O, K, V, A, N, C, E, D> | PropertyDescriptor = PlainWrappedDescriptorBase<O, K, V, A, N, C, E, any>> extends WrappedDescriptorCore<O, K, V, A, N, C, E, D> {
/**
* @description The active state of the descriptor.
* @public
* @type {(A | { onGet?: boolean; onSet?: boolean })}
*/
active: A | {
onGet?: boolean;
onSet?: boolean;
};
/**
* @description The enabled state of the descriptor.
* @public
* @type {N}
*/
enabled: N;
/**
* @description The index of the descriptor in the chain.
* @public
* @type {?number}
*/
index?: number;
/**
* @description The optional `get` method for the descriptor.
* @public
* @type {(this: O, descriptor?: D) => V}
*/
get: (this: O, descriptor?: D) => V;
/**
* @description The key of the descriptor.
* @public
* @type {K}
*/
key: K;
/**
* @description The on get hook function for the descriptor.
* @public
* @type {?GetterCallback<O, K>}
*/
onGet?: GetterCallback<O, K>;
/**
* @description The on set hook function for the descriptor.
* @public
* @type {?SetterCallback<O, K>}
*/
onSet?: SetterCallback<O, K>;
/**
* @description The previous descriptor.
* @public
* @type {D}
*/
previousDescriptor: D;
/**
* @description The private key for the descriptor.
* @public
* @type {PropertyKey}
*/
privateKey: PropertyKey;
/**
* @description The optional `set` method for the descriptor.
* @public
* @type {(this: O, value: V, descriptor?: D) => void}
*/
set: (this: O, value: V, descriptor?: D) => void;
/**
* Creates an instance of `WrappedDescriptorBase` child class.
* @constructor
* @param {O} object The object to define the descriptor on.
* @param {K} key The key of the object to define the descriptor on.
* @param {Partial<WrappedPropertyDescriptor<O, K, V, A, N, C, E, D>>} attributes The property descriptor to wrap.
*/
constructor(object: O, key: K, attributes: Partial<WrappedPropertyDescriptor<O, K, V, A, N, C, E, D>>);
}