Class ReflectionType

The ReflectionType implements a class that provides reflection for a reflected TypeScript type.

Use ReflectionType.get to get a reflection type for a TypeScript type.

Constructors

Properties

mutableType: Type

Gets the mutable system type.

systemType: Type

Gets the underlying system type.

Accessors

  • get fullyQualifiedName(): string
  • The fully qualified name of the type, including the namespace.

    Returns string

  • get isImmutable(): boolean
  • Determines if the type is immutable. Meaning the values cannot be modified.

    Returns boolean

  • get isSerializable(): boolean
  • Determines if the object is serializable.

    Returns boolean

  • get name(): string
  • The full name of given type.

    Returns string

Methods

  • Constructs a default value for the type.

    Returns any

    The constructed value or undefined if a default value is not constructible

    If the type is not default constructible undefined is returned. Types that have the SerializedObjectAttribute will be constructed by invoking their constructor.

  • Creates an instance of the specified type using the constructor that best matches the specified parameters.

    Type Parameters

    • T = any

    Parameters

    • Rest...constructorArguments: any[]

      Arguments to pass to the constructor.

    Returns T

    The newly created object.

  • Searches for the specified member field, using the specified binding constraints.

    Parameters

    • name: string

      The string containing the name of the member field to get.

    • OptionalisStatic: boolean

    Returns ReflectionField

    First member field that was found, if any. Otherwise null.

    Non-static fields may not have meta data, so if there is no explicit field the field may not be retrieved.

  • Searches for the specified members, using the specified binding constraints.

    Parameters

    • name: string

      The string containing the name of the members to get.

    Returns ReflectionMember[]

    An array containg all ReflectionMember of the type with the specified name.

  • Searches for the specified method.

    Parameters

    • name: string

      The string containing the name of the method to get.

    • isStatic: boolean

    Returns ReflectionMethod

    First ReflectionMethod that was found, if any. Otherwise undefined.

  • Searches for the specified property.

    Parameters

    • name: string

      The string containing the name of the property to get.

    • OptionalisStatic: boolean

    Returns ReflectionProperty

    First ReflectionProperty that was found, if any. Otherwise undefined.

  • Retrieves all custom attributes defined on this member.

    Parameters

    • OptionalincludeSuperClasses: boolean

    Returns Attribute[]

    All custom attributes defined on this member

  • Searches for the specified members, using the specified binding constraints.

    Parameters

    • isRecursive: boolean

      Enable to get members from super classes.

    Returns ReflectionMember[]

    An array of System.Reflection.MemberInfo objects representing the all public members

  • Returns all methods.

    Parameters

    • isRecursive: boolean

      Enable to get members from super classes.

    Returns ReflectionMethod[]

    Array of methods.

  • Retrieves a Attribute of a specified type that is applied to a specified member.

    Type Parameters

    Parameters

    • attributeType: ClassOf<T>

      The type of attribute to search for. Only attributes that are assignable to this type are returned.

    • OptionalincludeSuperClasses: boolean

      Determines if the attribute should be searched in super classes. Default: true.

    Returns T

    A custom attribute that matches T, or null if no such attribute is found.

    Attributes can be added to a class, field or method using decorators.

  • Retrieves custom attributes of a specified type that is applied to this member.

    Type Parameters

    Parameters

    • attributeType: ClassOf<T>

      The type of attribute to search for. Only attributes that are assignable to this type are returned.

    • OptionalincludeSuperClasses: boolean

    Returns T[]

    Custom attributes that matche T

  • Gets the type from which the current type directly inherits.

    Returns Type

    The base type of the current type, or null, if there is no base type.

  • Gets the class that declares this member.

    Returns Type

    The Type object for the class that declares this member.

  • Returns all methods with the specified Attribute.

    Type Parameters

    Parameters

    • attribute: ClassOf<T>

      Search for methods with the specified Attribute.

    • isRecursive: boolean

      Enable to get members from super classes.

    Returns {
        attribute: T;
        method: ReflectionMethod;
    }[]

    Array of methods.

  • Determines if the type is decorated with the specified Attribute.

    Type Parameters

    Parameters

    • attributeType: ClassOf<T>

      The type of attribute to search for. Only attributes that are assignable to this type are returned.

    • OptionalincludeSuperClasses: boolean

      Determines if the attribute should be searched in super classes. Default: true.

    Returns boolean

    True if the attribute was found on the type.

    Attributes can be added to a class, field or method using decorators.

  • Checks if this type is an array type.

    Returns boolean

    Whether this type is an array.

  • Determines whether an instance of the current type can be assigned from an instance of the specified Type.

    Parameters

    • sourceType: Type

      The type to compare with the current type.

    Returns boolean

    true if assignable.

  • Checks if this type is an enumeration type.

    Returns boolean

    Whether this type is an enum.

  • Gets a value indicating whether the type is one of the primitive types.

    Returns boolean

    true if the type is one of the primitive types; otherwise, false.

  • Checks if this class is subclass of given baseType or the baseType directly.

    Parameters

    • baseType: Type

      Base class to check.

    Returns boolean

    Whether this class is subclass of given base class.

  • Checks if this class is matches the specified otherType.

    Parameters

    • otherType: Type

      The tpye to check.

    Returns boolean

    Whether this class is the same as otherType.

  • Returns a String representing the name of the current Type.

    Returns string

  • Checks if the type is a subclass of given baseType or the baseType directly.

    Parameters

    • type: Type

      Type to check.

    • baseType: Type

      Base type to check.

    Returns boolean

    Whether the type is a subclass of given base type.