Delta-Pack - v0.2.9
    Preparing search index...

    Function SelfReferenceType

    • Create a self-reference for recursive types.

      Use this when a type needs to reference itself, such as tree structures or linked lists. The reference resolves to the containing named type.

      Returns UnifiedType<SelfReferenceType>

      // A tree node that contains children of the same type
      const TreeNode = ObjectType("TreeNode", {
      value: StringType(),
      children: ArrayType(SelfReferenceType()),
      });

      // A linked list node
      const ListNode = ObjectType("ListNode", {
      value: IntType(),
      next: OptionalType(SelfReferenceType()),
      });