Skip to content

tyneq


tyneq / ReflectionContext

Class: ReflectionContext<_T>

Defined in: src/utility/reflect.ts:19

The result of a reflect call. Provides typed access to the members of the reflected target.

Type Parameters

Type Parameter
_T extends object

Methods

members()

members(): readonly MemberDescriptor[]

Defined in: src/utility/reflect.ts:33

Returns descriptors for all own (and optionally inherited) members, excluding constructor.

Returns

readonly MemberDescriptor[]


methods()

methods(): readonly MethodDescriptor[]

Defined in: src/utility/reflect.ts:41

Returns descriptors for all method members (function-valued own properties), excluding constructor.

Returns

readonly MethodDescriptor[]


fields()

fields(): readonly DataDescriptor[]

Defined in: src/utility/reflect.ts:48

Returns descriptors for all data members (non-function value properties).

Returns

readonly DataDescriptor[]


accessors()

accessors(): readonly AccessorDescriptor[]

Defined in: src/utility/reflect.ts:55

Returns descriptors for all accessor members (get/set properties).

Returns

readonly AccessorDescriptor[]


get()

get(name): Maybe<MemberDescriptor>

Defined in: src/utility/reflect.ts:62

Returns the descriptor for the named member, or undefined if not found.

Parameters

ParameterType
namestring | symbol

Returns

Maybe<MemberDescriptor>


has()

has(name): boolean

Defined in: src/utility/reflect.ts:69

Returns true if a member with the given name exists on the target.

Parameters

ParameterType
namestring | symbol

Returns

boolean


getMethod()

getMethod(name): MethodDescriptor

Defined in: src/utility/reflect.ts:79

Returns the method descriptor for name, or throws ReflectionError if the member does not exist or is not a method.

Parameters

ParameterType
namestring | symbol

Returns

MethodDescriptor

Throws

when the member is absent or is not a method.


getAccessor()

getAccessor(name): AccessorDescriptor

Defined in: src/utility/reflect.ts:108

Returns the accessor descriptor for name, or throws ReflectionError if the member does not exist or is not an accessor.

Parameters

ParameterType
namestring | symbol

Returns

AccessorDescriptor

Throws

when the member is absent or is not an accessor.


hasMethod()

hasMethod(name): boolean

Defined in: src/utility/reflect.ts:135

Returns true if a method with the given name exists on the target.

Unlike has, this returns false if the member exists but is an accessor or data property.

Parameters

ParameterType
namestring | symbol

Returns

boolean


tryGetMethod()

tryGetMethod(name): Maybe<MethodDescriptor>

Defined in: src/utility/reflect.ts:143

Returns the method descriptor for name, or undefined if the member does not exist or is not a method. Never throws.

Parameters

ParameterType
namestring | symbol

Returns

Maybe<MethodDescriptor>