MapInfo

View source

ExtendsTypeInfo

Describes the key and value types in map reflection metadata.

MapInfo records type metadata for map entries; it does not contain a map or validate map values. Its serialized form is an object with kind: 'map', keyType, and valueType properties. It does not provide a default() factory; construct it with both type IDs.

Examples

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

const info = new MapInfo(typeid(String), typeid(Number))

info.getKeyType() // typeid(String)
info.getValueType() // typeid(Number)
info.serialize() // { kind: 'map', keyType: ..., valueType: ... }

Constructor


constructor(keyType: TypeId, valueType: TypeId)

View source

Creates map metadata for one key type and one value type.

The supplied type IDs are stored directly without copying or normalization.

Parameters

NameDescriptionDefault
keyType——
valueType——

Properties


Methods


serialize(): MapInfoSerial

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: MapInfo): MapInfoSerial

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: MapInfoSerial, out?: MapInfo): MapInfo

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 MapInfoSerial

View source

Checks whether a value has the serialized map metadata shape.

Validation accepts a non-null, non-array object with kind: 'map' and string keyType and valueType properties. Extra properties are allowed; this method validates the serial shape and does not create a MapInfo.

Parameters

NameDescriptionDefault
value——