---
url: >-
  https://node-ts.github.io/bus/api/bus-messages/type-aliases/MessageFieldType.md
---
[API reference](../../index.md) / [@node-ts/bus-messages](../index.md) / 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](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-messages/src/message-types.ts#L14)

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
