From 7a06a9673d5c18d61d6c8e76b18460c6233aed24 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 6 Sep 2026 11:53:29 +0000 Subject: [PATCH] docs(types): compile the types README's 7 blocks and drop its ledger entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part of objectui#5174 — batch 21 of the `UNGATED_DOCS` burn-down. `packages/types/README.md` leaves the ledger and all 7 of its ts/tsx blocks now compile against the built types. Two of them were PARSE failures: the discriminated-union excerpt ended on a dangling `|` before a comment, and the composable-nesting example used bare elision brackets in two slots. Both are fence shape, repaired by writing the real values rather than by declaring a fragment. The two semantic failures were ambient names — the `DataSource` excerpt and the Tailwind `ButtonSchema` example now carry real self-imports, and the excerpt is pinned to the shipped interface so it cannot drift silently. No `packages/**` source touched, no public type widened, no gate loosened, and no new fragment marker: declared fragments stay at 158, so all 7 blocks earn their coverage by compiling. The gate file's only change is the two lines of that one entry. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr --- packages/types/README.md | 40 +++++++++++++++++++++-------- scripts/check-doc-snippet-types.mjs | 2 -- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/packages/types/README.md b/packages/types/README.md index 8cba9476b5..218a411072 100644 --- a/packages/types/README.md +++ b/packages/types/README.md @@ -217,7 +217,12 @@ Backend integration: Types don't assume any specific backend: ```typescript -interface DataSource { +import type { DataSource, QueryParams, QueryResult } from '@object-ui/types'; + +// Two methods quoted from the shipped `DataSource`. `extends Pick` ties the +// quotation to the real interface: the day either member is renamed away or its +// return type changes, this block stops compiling. +interface DataSourceExcerpt extends Pick, 'find' | 'create'> { find(resource: string, params?: QueryParams): Promise>; create(resource: string, data: Partial): Promise; // Works with REST, GraphQL, ObjectQL, or anything @@ -229,6 +234,8 @@ interface DataSource { All components support `className` for Tailwind styling: ```typescript +import type { ButtonSchema } from '@object-ui/types'; + const button: ButtonSchema = { type: 'button', label: 'Click Me', @@ -241,11 +248,13 @@ const button: ButtonSchema = { Full TypeScript support with discriminated unions: ```typescript -type AnySchema = - | InputSchema - | ButtonSchema - | FormSchema - | /* 50+ more */; +import type { AnySchema, ButtonSchema, FormSchema, InputSchema } from '@object-ui/types'; + +// The shipped `AnySchema` carries 50+ members. These three are a slice of it, +// and the assignment below is what proves the slice really is part of the union. +type SchemaSlice = InputSchema | ButtonSchema | FormSchema; +declare const slice: SchemaSlice; +const anySchema: AnySchema = slice; function render(schema: AnySchema) { switch (schema.type) { @@ -260,6 +269,20 @@ function render(schema: AnySchema) { Components can nest indefinitely: ```typescript +import type { ContainerSchema, FlexSchema, SidebarSchema } from '@object-ui/types'; + +// The two leaves are annotated so the nesting below is checked against the +// shipped types rather than absorbed by `BaseSchema`'s index signature. +const sidebar: SidebarSchema = { + type: 'sidebar', + nav: [{ label: 'Home', href: '/' }] +}; + +const main: ContainerSchema = { + type: 'container', + children: [{ type: 'data-table', data: [] }] +}; + const page: FlexSchema = { type: 'flex', direction: 'col', @@ -268,10 +291,7 @@ const page: FlexSchema = { { type: 'flex', direction: 'row', - children: [ - { type: 'sidebar', nav: [...] }, - { type: 'container', children: [...] } - ] + children: [sidebar, main] } ] }; diff --git a/scripts/check-doc-snippet-types.mjs b/scripts/check-doc-snippet-types.mjs index 30beb8aa58..9beae7db59 100644 --- a/scripts/check-doc-snippet-types.mjs +++ b/scripts/check-doc-snippet-types.mjs @@ -741,8 +741,6 @@ const UNGATED_DOCS = { '7 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; plus TS2741x1 — candidate real defects, un-triaged', 'packages/react-runtime/README.md': '25 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; plus TS2813x1 TS2814x1 — candidate real defects, un-triaged', - 'packages/types/README.md': - '3 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies; 3 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines', }; // ── Fence scanning ───────────────────────────────────────────────────────────