CONSUME-AS-DATA-04: Iterate a TableView's typed rows
What it demonstrates
Section titled “What it demonstrates”A section whose sole content is a table promotes to a TableView you iterate as typed rows.
Builds on: CONSUME-AS-DATA-03: Walk a SectionView’s content surface
How it’s done
Section titled “How it’s done”A TypeScript program against the library API; inline comments show the resulting values and behavior.
const c = contract({ body: sections({}, [ section("Files", { content: table({ columns: ["File", "Kind", "Location"], cells: { Kind: z.enum(["add", "modify", "delete"]) }, }) }),])});
const files = c.read(src, { path: "task.md" }).body.files; // promoted TableViewfor (const row of files) console.log(row.File, row.Kind); // row.Kind is the enum unionconsole.log(files.rowCount, files.columns);Surfaces exercised
Section titled “Surfaces exercised”section() content: table()TableView promotioniteration over typed rows.rowCount.columns