TupleInfo

View source

ExtendsTypeInfo

Describes the ordered element types in tuple reflection metadata.

TupleInfo records one type ID for each tuple position; it does not contain a tuple or validate tuple values. Its serialized form is an object with kind: 'tuple' and an elementTypes array. It does not provide a default() factory; construct it with the complete ordered type list.

Examples

import { TupleInfo } from '@wimaengine/reflect'
import { typeid } from '@wimaengine/type'

const info = new TupleInfo([typeid(Number), typeid(String)])

info.getElement(0) // typeid(Number)
info.getElements() // [typeid(Number), typeid(String)]
info.serialize() // { kind: 'tuple', elementTypes: [...] }

Constructor


constructor(elementTypes: TypeId[])

View source

Creates tuple metadata from an ordered list of element type IDs.

The supplied array is stored directly rather than copied.

Parameters

NameDescriptionDefault
elementTypes——

Properties


elementTypes: TypeId[]

View source

Type IDs in tuple-position order.

The array is the one supplied to the constructor, so it remains live and can be changed through the instance. Treat it as read-only when using the metadata as a type description.

Methods


getElement(index: number): TypeId

View source

Returns the type ID recorded at a tuple position.

Parameters

NameDescriptionDefault
index

Zero-based tuple position.

—

Returns

The type ID, or undefined when the index is outside the current element array.

getElements(): readonly TypeId[]

View source

Returns the live array of tuple element type IDs.

The return type presents the array as read-only, but the returned value is the instance’s underlying array at runtime.

serialize(): TupleInfoSerial

View source

Serializes this metadata through the base contract.

Concrete metadata classes override this method with a subtype-specific serial shape. Calling the inherited method directly delegates to the abstract TypeInfo.serialize implementation and throws.

Throws

If this method is used without a concrete subtype implementation.

staticserialize(value: TupleInfo): TupleInfoSerial

View source

Abstract serialization hook for reflection metadata.

This base implementation never returns a serial value. Concrete subclasses should override it with their own serial shape.

Parameters

NameDescriptionDefault
value——

Throws

Always; TypeInfo is abstract and cannot be serialized directly.

staticdeserialize(value: TupleInfoSerial, out?: TupleInfo): TupleInfo

View source

Abstract deserialization hook for reflection metadata.

Concrete subclasses use the serial value to create or update metadata. The base implementation does not inspect either argument and always throws.

Parameters

NameDescriptionDefault
value——
out?—...

Throws

Always; TypeInfo is abstract and cannot be deserialized directly.

staticvalidateSerial(value: unknown): value is TupleInfoSerial

View source

Checks whether a value has the serialized tuple metadata shape.

Validation accepts a non-null, non-array object with kind: 'tuple' and an array whose present entries are string type IDs. Extra properties are allowed; this method validates the serial shape and does not create a TupleInfo.

Parameters

NameDescriptionDefault
value——