API reference / @node-ts/bus-messages / mergeMessageTypes
Function: mergeMessageTypes()
ts
function mergeMessageTypes(messageTypes): MessageTypes;Defined in: packages/bus-messages/src/merge-message-types.ts:66
Merges the message types of several message libraries into one, as the bus does with the message types passed to withMessageTypes(). Nothing is shared between calls, so each bus has its own.
Passing the same message types more than once is the same as passing them once.
Parameters
| Parameter | Type | Description |
|---|---|---|
messageTypes | MessageTypes[] | the message types to merge, usually the messageTypes export of each file generated by bus generate-message-types |
Returns
the merged message types
Throws
MessageTypeReferenceNotFound if some message types refer to a type they don't define
Throws
MessageTypesConflict if two of them define a $name or type key differently
Example
ts
import { messageTypes as orderMessageTypes } from '@my-org/order-messages'
import { messageTypes } from './message-types.generated'
const merged = mergeMessageTypes([orderMessageTypes, messageTypes])