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

    Function ReferenceType

    • Create a reference to another named type, class, or union.

      Use references to compose schemas from reusable type definitions. References work differently depending on the mode:

      • Schema mode: Pass a named type (ObjectType, UnionType, EnumType)
      • Decorator mode: Pass a class constructor or ClassUnionDef

      Type Parameters

      Parameters

      • ref: T

        The type to reference (named type, class, or union definition)

      Returns UnifiedType<{ type: "reference"; ref: T }>

      // Schema mode - reference other schema types
      const Position = ObjectType("Position", {
      x: FloatType(),
      y: FloatType(),
      });

      const Direction = EnumType("Direction", ["up", "down", "left", "right"]);

      const Player = ObjectType("Player", {
      position: ReferenceType(Position),
      facing: ReferenceType(Direction),
      });
      // Decorator mode - reference classes
      class Position {
      x = FloatType();
      y = FloatType();
      }

      class Player {
      position = ReferenceType(Position);
      }
    • Create a reference to another named type, class, or union.

      Use references to compose schemas from reusable type definitions. References work differently depending on the mode:

      • Schema mode: Pass a named type (ObjectType, UnionType, EnumType)
      • Decorator mode: Pass a class constructor or ClassUnionDef

      Type Parameters

      • C extends Function

      Parameters

      • cls: C

      Returns UnifiedType<ClassRef & { __class: C }>

      // Schema mode - reference other schema types
      const Position = ObjectType("Position", {
      x: FloatType(),
      y: FloatType(),
      });

      const Direction = EnumType("Direction", ["up", "down", "left", "right"]);

      const Player = ObjectType("Player", {
      position: ReferenceType(Position),
      facing: ReferenceType(Direction),
      });
      // Decorator mode - reference classes
      class Position {
      x = FloatType();
      y = FloatType();
      }

      class Player {
      position = ReferenceType(Position);
      }
    • Create a reference to another named type, class, or union.

      Use references to compose schemas from reusable type definitions. References work differently depending on the mode:

      • Schema mode: Pass a named type (ObjectType, UnionType, EnumType)
      • Decorator mode: Pass a class constructor or ClassUnionDef

      Type Parameters

      • U extends ClassUnionDef<string, readonly (new (...args: any[]) => any)[]>

      Parameters

      • union: U

      Returns UnifiedType<ClassUnionRef<U>>

      // Schema mode - reference other schema types
      const Position = ObjectType("Position", {
      x: FloatType(),
      y: FloatType(),
      });

      const Direction = EnumType("Direction", ["up", "down", "left", "right"]);

      const Player = ObjectType("Player", {
      position: ReferenceType(Position),
      facing: ReferenceType(Direction),
      });
      // Decorator mode - reference classes
      class Position {
      x = FloatType();
      y = FloatType();
      }

      class Player {
      position = ReferenceType(Position);
      }