@typescript-package/wrap-property
Version:
A lightweight TypeScript package for wrapping object properties.
29 lines (28 loc) • 2.41 kB
TypeScript
import { WrapPropertyBase } from './wrap-property-base.abstract';
import { PropertyControllerShape } from '@typedly/controller';
import { WrappedPropertyDescriptor } from '@typedly/descriptor';
/**
* @description The concrete class for wrapping object properties.
* @export
* @class WrapProperty
* @template {object | (new () => any)} T The type of the target object or class to wrap the property of the given `key`.
* @template {Record<PropertyKey, any>} [O=(T extends new () => T ? ( T extends { prototype: infer P } ? P : never) : T)] The object type of captured `T`.
* @template {keyof O extends string | symbol ? keyof O : never} [K=keyof O extends string | symbol ? keyof O : never] The key type of the property to wrap.
* @template {boolean} [A=boolean] The type of active property.
* @template {boolean} [C=boolean] The type of configurable property.
* @template {boolean} [E=boolean] The type of enumerable property.
* @template {WrappedPropertyDescriptor<O, K, C, E>} [D=WrappedPropertyDescriptor<O, K, C, E>] The type of descriptor constrained by the `WrappedPropertyDescriptor`.
* @template {PropertyControllerShape<O, K, A, C, E, D>} [Controller=PropertyControllerShape<O, K, A, C, E, D>] The type of controller that controls the wrapping behavior.
* @extends {WrapPropertyBase<T, O, K, C, E, D>}
*/
export declare class WrapProperty<O extends Record<PropertyKey, any>, K extends keyof O extends string | symbol ? keyof O : never = keyof O extends string | symbol ? keyof O : never, A extends boolean = boolean, F extends boolean = boolean, C extends boolean = boolean, E extends boolean = boolean, D extends WrappedPropertyDescriptor<O, K, A, F, C, E> = WrappedPropertyDescriptor<O, K, A, F, C, E>, Controller extends PropertyControllerShape<O, K, A, F, C, E, D> = PropertyControllerShape<O, K, A, F, C, E, D>> extends WrapPropertyBase<O, K, A, F, C, E, D> {
/**
* Creates an instance of `WrapProperty`.
* @constructor
* @param {O} object The target object or class to wrap the property of the given `key`.
* @param {K} key The key of the property to wrap.
* @param {?D} [descriptor] The descriptor of the property to wrap.
* @param {?new (descriptor?: D) => Controller} [controller] The controller that controls the wrapping behavior.
*/
constructor(object: O, key: K, descriptor?: D, controller?: new (descriptor?: D) => Controller);
}