Skip to content

docs(html): name the six document shapes as interfaces so the API tier renders them - #185

Closed
laithalsaadoon wants to merge 1 commit into
mainfrom
docs/html-doc-shapes
Closed

laithalsaadoon wants to merge 1 commit into
mainfrom
docs/html-doc-shapes

Conversation

@laithalsaadoon

Copy link
Copy Markdown
Contributor

Type-only change in packages/html/src/document.ts, opened for review and left unmerged: it sits under packages/*/src, so it is outside the maintenance job's merge authority even though no runtime line changes.

What changes

The six document shapes (MemoryMetas, MemoryLink, Facet, Citation, ArticleExtractions, MemoryDoc) were declared as export type X = typeof X.Type. Each is now an interface that extends that same type:

type MemoryDocShape = typeof MemoryDoc.Type
/** The parsed shape `MemoryDoc` decodes to, named so a signature can refer to it. */
export interface MemoryDoc extends MemoryDocShape {}

The const and the interface merge under one name, so every import site keeps compiling unchanged. mise run check on the branch is green (typecheck across the workspace, lint, every test tier).

Why

The API tier (/api/<package>/ on the docs site, generated by typedoc) is about to add @memhtml/html. With the aliases, TypeDoc expands the shape inline wherever a signature uses it, and typedoc-plugin-markdown renders the nested article and metas literals as escaped \{ prose, which apps/docs/tests/figures.test.ts rejects. Measured with the typedoc CLI on 26480c7: 7 brace hits (metaPairs, serializeMemory, parseMemory) and 6 warnings for {@link MemoryMetas.status}, which cannot resolve against a const. With the interfaces: 0 hits, 0 warnings, and parseMemory renders as Effect<MemoryDoc, InvalidMemory> with MemoryDoc a link. The same pattern was used for @memhtml/llm in #170.

One caveat to weigh

An interface does not get the implicit index signature an object-literal type alias gets, so a consumer that assigned a MemoryDoc to Record<string, unknown> would stop compiling. The workspace typecheck found no such site; an out-of-tree consumer might.

The docs slice that depends on this is opened separately with this branch as its base.

…r renders them

MemoryMetas, MemoryLink, Facet, Citation, ArticleExtractions and MemoryDoc
were `export type X = typeof X.Type` aliases. TypeDoc expanded each inline
wherever a signature used it, and typedoc-plugin-markdown rendered the nested
literals as escaped braces (7 hits across metaPairs, serializeMemory and
parseMemory) that the figures probe rejects; the 6 {@link MemoryMetas.status}
references also failed to resolve against the const. As interfaces extending
the same Schema.Struct type the const and the type merge under one name, every
import site compiles unchanged, and the page renders 0 hits and 0 warnings.
Type-only; no runtime line changes. mise run check 68/68.
Copilot AI lite review requested due to automatic review settings September 14, 2026 07:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@laithalsaadoon

Copy link
Copy Markdown
Contributor Author

Closed in favor of #264, which consolidates the four API-tier PRs (#185 html document shapes, #186 the @memhtml/html API page, #199 index types, #201 sleep types) into one branch built by merge commits from main a1c6913. The slice conflict on apps/docs/astro.config.ts and api/index.md was resolved by appending the html block after llm; the block is byte-identical to #186's. Gate 68/68, including the docs build that writes /api/html/ and the MDX brace probe. The branch here is kept, so this PR can be reopened if the parts should land apart.

laithalsaadoon added a commit that referenced this pull request Oct 20, 2026
… @memhtml/html to it (#264)

Three type-only edits under `packages/*/src` plus the `@memhtml/html` API page. No runtime line changes: the emitted JavaScript is identical.

What changes:
- `packages/html/src/document.ts`: the six document shapes (`MemoryMetas`, `MemoryLink`, `Facet`, `Citation`, `ArticleExtractions`, `MemoryDoc`) become interfaces that extend `typeof X.Type`, so the const and the interface merge under one name and every import site compiles unchanged.
- `@memhtml/html` API page: a `starlightTypeDoc` instance writes `/api/html/` from the package's single import path; a new `packages/html/README.md` opens the page; the tier index gains a row and the sidebar a group.
- `packages/index/src`: `type` exports for five interfaces that exported signatures already reference (`ArchivedMatch`, `EmbedMissingOptions`, `StoreChangedPath`, `StoreStatusEntry`, `StoreTreeEntry`); `IndexStateRow` becomes an interface the same way as the html shapes; six `{@link}`s to private names become code spans.

Why: typedoc expands a `typeof X.Type` alias inline wherever a signature uses it, and typedoc-plugin-markdown prints an inline object literal inside a type argument as escaped `\{` prose, which `apps/docs/tests/figures.test.ts` rejects. The interfaces and named types render as links instead. Measured with the typedoc CLI: html went from 7 brace hits and 6 warnings to 0 and 0; index from 12 warnings and 1 hit (plus 13 hits from html's aliases) to 0 and 0. With these on main, the index API page (`/api/index/`) can follow as a docs-only slice.

One caveat: an interface does not get the implicit index signature an object-literal type alias gets, so an out-of-tree consumer that assigned a `MemoryDoc` or an `IndexStateRow` to `Record<string, unknown>` would stop compiling. The workspace typecheck finds no such site.

Consolidates #185, #186, #199 and #201, closed in favor of this branch. The `packages/sleep` part of the original branch no longer applies: 0.16.0 removed that package.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants