@adobe/data - v0.10.30
    Preparing search index...

    Function toTypeScript

    • Converts a Schema to one or more TypeScript type declarations.

      The generated type is the source-text equivalent of Schema.ToType<typeof schema>: it mirrors that mapping (including its deep-readonly default — a schema node opts out with mutable: true) so the two stay interchangeable. The generator:

      • Recurses the whole schema tree (properties, array items, oneOf/allOf/ anyOf, function signatures, and observe/promise/generator value types).
      • Deduplicates repeated object shapes. Any object shape that would appear more than once in the output (the same structure used in ≥2 places, or the element of a fixed-length tuple of length ≥2) is pre-declared once at the top as a named interface and referenced by name everywhere it occurs. Shapes used exactly once stay inlined. The name is the shape's title (PascalCased) when present, else the referencing property key or parameter name, else a generated Shape<n>.
      • Emits descriptions as // comments directly above the declaration, property, or function they annotate (one comment line per line of the description).
      • Omits members hidden from the audience (default "agent"): an object property whose schema external policy denies that channel (see resolveExternalInvocation) is left out entirely, at any depth. So by default a member marked external: { agent: false } is never shown to an agent. "link" keeps only link: true members (default-deny); "all" emits every member.

      A schema that resolves to an object is emitted as an interface; anything else as a type alias. The result references the ambient names Blob, Promise, AsyncGenerator, TypedBuffer (@adobe/data) and Observe (@adobe/data/observe) for the corresponding schema constructors, and each typeName verbatim; the caller supplies those imports.

      Parameters

      • schema: Schema.Schema
      • name: string
      • options: { audience?: "all" | "link" | "agent" } = {}

      Returns string

      toTypeScript(
      {
      type: "object",
      description: "A line segment",
      properties: {
      from: { title: "Point", type: "object", properties: { x: { type: "number" }, y: { type: "number" } }, required: ["x", "y"] },
      to: { title: "Point", type: "object", properties: { x: { type: "number" }, y: { type: "number" } }, required: ["x", "y"] },
      },
      required: ["from", "to"],
      },
      "Line",
      );
      // interface Point {
      // readonly x: number;
      // readonly y: number;
      // }
      //
      // // A line segment
      // interface Line {
      // readonly from: Point;
      // readonly to: Point;
      // }