mergeTreeElements()function

mergeTreeElements(primary: T, secondary: TreeElement): T
ParamType
primaryT
The element whose identity is preserved and whose set fields win. required
secondaryTreeElement
The element whose metadata fills any gaps in primary. required
    .keystring
required readonly
    .type`tree-${string}`
required readonly
Return
T
A new TreeElement with primary's identity and the merged metadata of both.

Merge two tree elements — primary keeps its identity (type, key, source); secondary contributes any
metadata primary does not already have.

  • title and description are taken from primary when set, otherwise from secondary — primary stays canonical
    but a missing field falls back rather than disappearing.
  • content and children from both are concatenated (primary first).

Examples

mergeTreeElements(tsElement, mdElement) // ts identity + md prose