Skip to content

API reference / @node-ts/bus-messages / MessageFieldType

Type Alias: MessageFieldType ​

ts
type MessageFieldType = 
  | "Date"
  | "BigInt"
  | {
  type: string;
}
  | {
  array: MessageFieldType;
}
  | {
  set: MessageFieldType | "plain";
}
  | {
  keys?: "number";
  map: MessageFieldType | "plain";
}
  | {
  record: MessageFieldType;
};

Defined in: packages/bus-messages/src/message-types.ts:14

How a field is restored after its message has been parsed from JSON. Fields that JSON already represents (strings, numbers, booleans, null, plain objects and arrays of them) aren't listed.

  • 'Date': an ISO string or epoch number becomes a Date
  • 'BigInt': a string or number becomes a bigint
  • { type }: an object is restored using the entry with that key in MessageTypes.types
  • { array }: each item of an array is restored as the given type
  • { set }: an array becomes a Set, with each item restored as the given type, or kept as-is for 'plain'
  • { map }: an object becomes a Map of its entries, with each value restored as the given type, or kept as-is for 'plain'. Keys stay strings unless keys is 'number'
  • { record }: each value of an object used as a dictionary is restored as the given type

Released under the MIT License.