const PACKAGE_ID = "tst-reflect" ; /**
 * Kind of type
 */ export enum TypeKind { /**
     * Interface
     */ Interface , /**
     * Class
     */ Class , /**
     * Native JavaScript/TypeScript type
     */ Native , /**
     * Container for other types in case of types union or intersection
     */ Container , description TransientTypeReference , description Object , example LiteralType , example Tuple , description TypeParameter , /**
     * Conditional type
     */ ConditionalType = 9 } internal export interface ConditionalTypeDescription { /**
     * Extends type
     */ e : Type ; /**
     * True type
     */ tt : Type ; /**
     * False type
     */ ft : Type ; } export interface ConditionalType { /**
     * Extends type
     */ extends : Type ; /**
     * True type
     */ trueType : Type ; /**
     * False type
     */ falseType : Type ; } internal export interface ParameterDescription { n : string ; t : Type ; o : boolean ; } internal export interface PropertyDescription { n : string ; t : Type ; d ? : Array < DecoratorDescription > ; } /**
 * Property description
 */ export interface Property { /**
     * Property name
     */ name : string ; /**
     * Property type
     */ type : Type ; /**
     * Property decorators
     */ decorators : Array < Decorator > ; } internal export interface DecoratorDescription { n : string ; fn : string ; } /**
 * Decoration description
 */ export interface Decorator { /**
     * Decorator name
     */ name : string ; /**
     * Decorator full name
     */ fullName ? : string ; } /**
 * Method parameter description
 */ export interface MethodParameter { /**
     * Parameter name
     */ name : string ; /**
     * Parameter type
     */ type : Type ; /**
     * Parameter is optional
     */ optional : boolean ; } internal export interface ConstructorDescription { params : Array < ParameterDescription > ; } /**
 * Constructor description object
 */ export interface Constructor { /**
     * Constructor parameters
     */ parameters : Array < MethodParameter > ; } internal export interface TypeProperties { /**
     * Type name
     */ n ? : string ; /**
     * Type fullname
     */ fn ? : string ; /**
     * TypeKind
     */ k : TypeKind ; /**
     * Constructors
     */ ctors ? : Array < ConstructorDescription > ; /**
     * Properties
     */ props ? : Array < PropertyDescription > ; /**
     * Decorators
     */ decs ? : Array < DecoratorDescription > ; /**
     * Generic type parameters
     */ tp ? : Array < Type > ; /**
     * Is union type
     */ union ? : boolean ; /**
     * Is intersection type
     */ inter ? : boolean ; /**
     * Unified or intersecting types
     */ types ? : Array < Type > ; /**
     * Ctor getter
     */ ctor ? : ( ) => Function ; /**
     * Extended base type
     */ bt ? : Type ; /**
     * Implemented interface
     */ iface ? : Type ; /**
     * Literal value
     */ v ? : any ; /**
     * Type arguments
     */ args ? : Array < Type > ; /**
     * Default type
     */ def ? : Type ; /**
     * Constraining type
     */ con ? : Type ; /**
     * Conditional type description
     */ ct ? : ConditionalTypeDescription ; } const typesMetaCache = { } ; /**
 * Object representing TypeScript type in memory
 */ export class Type { public static readonly Object : Type ; private readonly _ctor ? : ( ) => Function ; private readonly _kind : TypeKind ; private readonly _name : string ; private readonly _fullName : string ; private readonly _isUnion : boolean ; private readonly _isIntersection : boolean ; private readonly _types ? : Array < Type > ; private readonly _properties : Array < Property > ; private readonly _decorators : Array < Decorator > ; private readonly _constructors : Array < Constructor > ; private readonly _typeParameters : Array < Type > ; private readonly _baseType ? : Type ; private readonly _interface ? : Type ; private readonly _literalValue ? : any ; private readonly _typeArgs : Array < Type > ; private readonly _conditionalType ? : ConditionalType ; private readonly _genericTypeConstraint ? : Type ; private readonly _genericTypeDefault ? : Type ; internal constructor ( description ) { if ( new . target != TypeActivator ) { throw new Error ( "You cannot create instance of Type manually!" ) ; } this . _name = description . n || "" ; this . _fullName = description . fn || description . n || "" ; this . _kind = description . k ; this . _constructors = description . ctors ?. map ( Type . mapConstructors ) || [ ] ; this . _properties = description . props ?. map ( Type . mapProperties ) || [ ] ; this . _decorators = description . decs ?. map ( Type . mapDecorators ) || [ ] ; this . _typeParameters = description . tp || [ ] ; this . _ctor = description . ctor ; this . _baseType = description . bt ?? ( description . ctor == Object ? undefined : Type . Object ) ; this . _interface = description . iface ; this . _isUnion = description . union || false ; this . _isIntersection = description . inter || false ; this . _types = description . types ; this . _literalValue = description . v ; this . _typeArgs = description . args || [ ] ; this . _conditionalType = description . ct ? { extends : description . ct . e , trueType : description . ct . tt , falseType : description . ct . ft } : undefined ; this . _genericTypeConstraint = description . con ; this . _genericTypeDefault = description . def ; } internal param typeId public static _getTypeMeta ( typeId ) { const type = typesMetaCache [ typeId ] ; if ( ! type ) { throw new Error ( `Unknown type identifier '${ typeId }'. Metadata not found.` ) ; } return type ; } internal param typeId param type public static _storeTypeMeta ( typeId , type ) { typesMetaCache [ typeId ] = type ; } internal param d private static mapDecorators ( d ) { return ( { name : d . n , fullName : d . fn } ) ; } internal param p private static mapProperties ( p ) { return ( { name : p . n , type : p . t , decorators : p . d ?. map ( Type . mapDecorators ) || [ ] } ) ; } internal param c private static mapConstructors ( c ) { return ( { parameters : c . params . map ( p => ( { name : p . n , type : p . t , optional : p . o } ) ) } ) ; } /**
     * Returns information about generic conditional type.
     */ get condition ( ) : ConditionalType | undefined { return this . _conditionalType ; } /**
     * Returns a value indicating whether the Type is container for unified Types or not
     */ get union ( ) : boolean { return this . _isUnion ; } /**
     * Returns a value indicating whether the Type is container for intersecting Types or not
     */ get intersection ( ) : boolean { return this . _isIntersection ; } /**
     * List of underlying types in case Type is union or intersection
     */ get types ( ) : Array < Type > | undefined { return this . _types ; } /**
     * Constructor function in case Type is class
     */ get ctor ( ) : Function | undefined { return this . _ctor ?. ( ) ; } description get baseType ( ) : Type | undefined { return this . _baseType ; } description get fullName ( ) : string { return this . _fullName ; } /**
     * Get type name
     */ get name ( ) : string { return this . _name ; } /**
     * Get kind of type
     */ get kind ( ) : TypeKind { return this . _kind ; } param type is ( type ) { return this . _fullName == type . _fullName ; } /**
     * Returns a value indicating whether the Type is a class or not
     */ isClass ( ) { return this . kind == TypeKind . Class ; } /**
     * Returns a value indicating whether the Type is a interface or not
     */ isInterface ( ) { return this . kind == TypeKind . Interface ; } /**
     * Returns a value indicating whether the Type is an literal or not
     */ isLiteral ( ) { return this . _kind == TypeKind . LiteralType ; } /**
     * Get underlying value in case of literal type
     */ getLiteralValue ( ) { return this . _literalValue ; } /**
     * Returns a value indicating whether the Type is an object literal or not
     */ isObjectLiteral ( ) { return this . _kind == TypeKind . Object ; } /**
     * Returns array of properties
     */ getTypeParameters ( ) { return this . _typeParameters ; } /**
     * Return type arguments in case of generic type
     */ getTypeArguments ( ) { return this . _typeArgs ; } /**
     * Returns constructor description when Type is a class
     */ getConstructors ( ) { if ( ! this . isClass ( ) ) { return undefined ; } return this . _constructors ; } /**
     * Returns interface which this type implements
     */ getInterface ( ) { return this . _interface ; } /**
     * Returns array of properties
     */ getProperties ( ) { return this . _properties ; } /**
     * Returns array of decorators
     */ getDecorators ( ) { return this . _decorators ; } param target isAssignableTo ( target ) { return this . fullName == target . fullName || this . _baseType ?. isAssignableTo ( target ) || this . _interface ?. isAssignableTo ( target ) || false ; } /**
     * Check if this type is a string
     */ isString ( ) { return ( this . kind == TypeKind . Native || this . kind == TypeKind . LiteralType ) && this . name == "string" ; } /**
     * Check if this type is a number
     */ isNumber ( ) { return ( this . kind == TypeKind . Native || this . kind == TypeKind . LiteralType ) && this . name == "number" ; } /**
     * Check if this type is a boolean
     */ isBoolean ( ) { return ( this . kind == TypeKind . Native || this . kind == TypeKind . LiteralType ) && this . name == "boolean" ; } /**
     * Check if this type is an array
     */ isArray ( ) { return ( this . kind == TypeKind . Native || this . kind == TypeKind . LiteralType ) && this . name == "Array" ; } } class TypeActivator extends Type { } ( Type as any ) . Object = Reflect . construct ( Type , [ { n : "Object" , fn : "Object" , ctor : Object , k : TypeKind . Native } ] , TypeActivator ) ; /**
 * Returns Type of generic parameter
 */ export function getType < T > ( ) ; internal export function getType < T > ( description ? , typeId ? ) { if ( typeof description == "number" ) { return Type . _getTypeMeta ( description ) ; } if ( description && description . constructor === Object ) { const type = Reflect . construct ( Type , [ description ] , TypeActivator ) ; if ( typeId ) { Type . _storeTypeMeta ( typeId , type ) ; } return type ; } return undefined ; } getType . __tst_reflect__ = true ; reflectDecorator export function reflect < TType > ( ) { getType < TType > ( ) ; return function < T > ( Constructor ) { } ; } /**
 * To identify functions by package
 */ export const TYPE_ID_PROPERTY_NAME = "__tst_reflect__" ; /**
 * Name of JSDoc comment marking method as it use type of generic parameter.
 */ export const REFLECT_GENERIC_DECORATOR = "reflectGeneric" ; type { string } export const REFLECT_DECORATOR_DECORATOR = "reflectDecorator" ; /**
 * Name of the getType() function
 */ export const GET_TYPE_FNC_NAME = "getType" ;