json-dom
    Preparing search index...

    Function withTrait

    • Give an item a trait: the trait's defaults and the given data are put on the item (the same object, not a copy), and it is added to the item's has map.

      Type Parameters

      • Item extends CoreItem
      • Trait extends "render"

      Parameters

      • item: Item

        The item which gains the trait.

      • trait: Trait

        The name of the trait.

      • data: TraitRegistry[Trait]

        The data the trait puts on the item.

      Returns Item & { has: { [Name in "render"]: true } } & UnionToIntersection<
          TraitRegistry[Trait],
      >

      The same item, now with the trait.