Delta-Pack - v0.2.9
    Preparing search index...

    Function RecordType

    • Create a map/dictionary type with typed keys and values.

      Records are encoded as key-value pairs. Keys must be string or int types. At runtime, records are represented as JavaScript Map objects.

      Type Parameters

      • const K extends StringType | IntType

        The key type (StringType or IntType)

      • const V extends ValueType

        The value type

      Parameters

      • key: K

        The type of keys in the map

      • value: V

        The type of values in the map

      Returns UnifiedType<{ type: "record"; key: K; value: V }>

      const PlayerStats = ObjectType("PlayerStats", {
      // Map from player name to score
      scoresByName: RecordType(StringType(), IntType()),
      // Map from player ID to position
      positionsById: RecordType(IntType(), ReferenceType(Position)),
      });