FunctionInfo

View source

ExtendsTypeInfo

Describes the parameter and return type IDs in function reflection metadata.

FunctionInfo records parameter types in call order and one return type; it describes a function signature rather than a callable function. Its serialized form is an object with kind: 'function', a parameterTypes array, and a returnType.

Examples

const info = new FunctionInfo(['number', 'number'], 'number')
info.getParameter(0) // 'number'
info.serialize() // { kind: 'function', parameterTypes: [...], returnType: 'number' }

Constructor


constructor(parameterTypes: TypeId[], returnType: TypeId)

View source

Creates function-signature metadata.

The constructor stores the supplied parameter array directly, so later mutations to that array are reflected by this metadata. The serialized form uses a copied parameter array and records the return type separately. FunctionInfo has no default factory; provide both parts of the signature.

Parameters

NameDescriptionDefault
parameterTypes——
returnType——

Properties


parameterTypes: TypeId[]

View source

Type IDs for the function’s parameters, in call order.

Methods


getParameter(index: number): TypeId

View source

Returns the parameter type ID at an index.

Parameters

NameDescriptionDefault
index——

Returns

The type ID, or undefined outside the parameter array.

getParameters(): readonly TypeId[]

View source

Returns the live parameter type array.

The API exposes it as read-only in its type annotation, but the returned array is the instance’s underlying array at runtime.

staticserialize(value: FunctionInfo): FunctionInfoSerial

View source

Serializes function metadata without exposing its parameter array.

The serial contains exactly { kind: 'function', parameterTypes, returnType }. parameterTypes is a shallow copy, while each type ID and returnType is preserved as-is.

Parameters

NameDescriptionDefault
value——

staticdeserialize(value: FunctionInfoSerial, out?: FunctionInfo): FunctionInfo

View source

Restores a function signature from its serialized type IDs.

Without out, this creates a new instance. With out, it clears and repopulates the existing parameter array, assigns the return type, and returns the same instance. The serial is assumed to have been validated first.

Parameters

NameDescriptionDefault
value——
out?—...

staticvalidateSerial(value: unknown): value is FunctionInfoSerial

View source

Checks whether a value has the serialized function metadata shape.

Validation requires a non-null, non-array object with kind: 'function', an array of string parameterTypes, and a string returnType. Extra properties are allowed; this method validates the serial shape and does not create a FunctionInfo.

Parameters

NameDescriptionDefault
value——