UNPKG

@kephas/reflection

Version:

Provides reflection capabilities, like TypeInfoRegistry, ITypeInfo, and IProperty.

132 lines (131 loc) 4.31 kB
import { Type } from '@kephas/core'; import { DisplayInfo } from './displayInfo'; import { ElementInfo } from './elementInfo'; import { IPropertyInfo, ITypeInfo, ITypeInfoRegistry } from './interfaces'; /** * Provides reflective information about a type. * * @export * @class TypeInfo * @extends {ElementInfo} */ export declare class TypeInfo extends ElementInfo implements ITypeInfo { /** * Gets the type's namespace. * * @type {string} * @memberof TypeInfo */ readonly namespace?: string; /** * Gets the type's properties. * * @type {IIPropertyInfo[]} * @memberof TypeInfo */ readonly properties: IPropertyInfo[]; /** * Gets the instance constructor. * * @memberof TypeInfo */ readonly type?: Type<any>; /** * Gets the default value of the property. * * @type {*} * @memberof TypeInfo */ readonly defaultValue?: any; /** * Gets a value indicating whether this type is an array. * * @type {boolean} True if the type is an array, false otherwise. * @memberof TypeInfo */ readonly isArray: boolean; /** * Gets a value indicating whether this type is an enumeration. * * @type {boolean} True if the type is an enumeration, false otherwise. * @memberof TypeInfo */ readonly isEnum: boolean; /** * Gets a value indicating whether this type is the boolean type. * * @type {boolean} True if the type is the boolean type, false otherwise. * @memberof TypeInfo */ get isBoolean(): boolean; /** * Gets a value indicating whether this type is the number type. * * @type {boolean} True if the type is the number type, false otherwise. * @memberof TypeInfo */ get isNumber(): boolean; /** * Gets a value indicating whether this type is the string type. * * @type {boolean} True if the type is the string type, false otherwise. * @memberof TypeInfo */ get isString(): boolean; /** * Gets a value indicating whether this type is the symbol type. * * @type {boolean} True if the type is the symbol type, false otherwise. * @memberof TypeInfo */ get isSymbol(): boolean; /** * Gets a value indicating whether this type is the any type. * * @type {boolean} True if the type is the any type, false otherwise. * @memberof TypeInfo */ get isAny(): boolean; /** * Creates an instance of TypeInfo. * * @param {string} name The type name. * @param {string} [namespace] The type namespace. * @param {string} [fullName] Optional. The full name of the type. * @param {DisplayInfo} [displayInfo] Optional. The display information. * @param {IPropertyInfo[]} [properties] Optional. The properties. * @param {Type<*>} [type] Optional. The instantiable type. * @param {boolean} [isArray] Optional. Indicates whether the type is an array. * @param {boolean} [isEnum] Optional. Indicates whether the type is an enumeration. * @param {*} [defaultValue] Optional. The type's default value. * @param {ITypeInfoRegistry} [registry] The root type info registry. * @memberof TypeInfo */ constructor({ name, namespace, fullName, displayInfo, properties, type, isArray, isEnum, defaultValue, registry, ...args }: { name?: string; namespace?: string; fullName?: string; displayInfo?: DisplayInfo; properties?: { name: string; fullName?: string; displayInfo?: DisplayInfo; valueType?: ITypeInfo | string; canRead?: boolean; canWrite?: boolean; isRequired?: boolean; isStatic?: boolean; defaultValue?: any; [key: string]: any; }[]; type?: Type<any>; isArray?: boolean; isEnum?: boolean; defaultValue?: any; registry?: ITypeInfoRegistry; [key: string]: any; }); private static _getName; private static _getFullName; private static _getNamespace; }