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;
// }
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 withmutable: true) so the two stay interchangeable. The generator:oneOf/allOf/anyOf, function signatures, and observe/promise/generator value types).interfaceand referenced by name everywhere it occurs. Shapes used exactly once stay inlined. The name is the shape'stitle(PascalCased) when present, else the referencing property key or parameter name, else a generatedShape<n>.descriptions as//comments directly above the declaration, property, or function they annotate (one comment line per line of the description).audience(default"agent"): an object property whose schemaexternalpolicy denies that channel (seeresolveExternalInvocation) is left out entirely, at any depth. So by default a member markedexternal: { agent: false }is never shown to an agent."link"keeps onlylink: truemembers (default-deny);"all"emits every member.A schema that resolves to an object is emitted as an
interface; anything else as atypealias. The result references the ambient namesBlob,Promise,AsyncGenerator,TypedBuffer(@adobe/data) andObserve(@adobe/data/observe) for the corresponding schema constructors, and eachtypeNameverbatim; the caller supplies those imports.