doc-examples: extend the @example typecheck guard to the satellite packages, starting with prisma
packages/core/src/doc-examples.spec.ts extracts every ```ts fence under a
TSDoc @example, gives it an import preamble built from index.ts, and
typechecks the lot with tsc. A renamed export fails on the preamble import
(TS2305/TS2724) rather than as an ignorable TS2304, so the guard is real.
No satellite package runs it. CLAUDE.md already names the next step:
@unthrown/prisma's 34 examples are the obvious next application.
This is the same drift vector that shipped fromSchema(schema, input) for a
curried API and a stale Prisma error model in the agent skill. Prose rots
silently; tsc does not.
Current @example counts
| package | @example tags |
|---|---|
prisma |
~80 |
core |
39 (already guarded) |
effect |
6 |
boxed |
4 |
neverthrow |
4 |
orpc |
3 |
standard-schema |
2 |
vitest |
1 |
oxlint |
0 |
Two corrections to the obvious framing:
- The
CLAUDE.mdfigure of 34 is stale — prisma is at roughly 80 tags now, which makes it both the highest-value target and the slowesttscrun. oxlinthas zero@exampleblocks, so it is not in scope here. Its drift surface is the hand-maintainedskills/unthrown/markdown, andpackages/oxlint/src/skill.test.tsalready pins the mechanically-checkable part of that.
Scope
Step 1 — prisma only. It carries most of the risk and will expose whatever the generalisation actually needs. Two things the core spec does not handle as-is:
- The preamble is built from the package's own
index.ts. Prisma examples also referenceunthrowncore exports,@prisma/client, and the generated test client, so the preamble needs more than one module. - The spec strips
import … from "unthrown"lines from each snippet (doc-examples.spec.ts:88). That list has to become per-package.
Step 2 — decide the sharing vehicle before the second copy. The spec is 131
lines. Copying it into seven more packages is the wrong shape, and this repo has
no tools/ package to hold shared test machinery (shared config is deliberately
external — @btravstack/tsconfig et al). Options worth weighing: a non-published
internal workspace package; a vitest workspace-level setup module; or accepting
duplication for the three or four packages that actually warrant it. Whichever
wins, knip and the coverage config need to agree with it.
Step 3 — roll out to standard-schema, effect, neverthrow, boxed,
orpc, vitest.
Notes
- Each new spec needs
typescriptresolvable from the package (core reaches it viacreateRequire(...).resolve("typescript/bin/tsc")). - Keep the
expect(examples.length).toBeGreaterThan(N)guard-on-the-guard, with N set per package — without it a broken extraction regex passes vacuously. - The 60s timeout core uses will need raising for prisma.
Closed by #216, which took a different direction — runnable examples/ packages rather than generalising core's extractor. Recording one thing for anyone who revisits this, because the count in the issue body is wrong and it was load-bearing for the argument.
The table lists prisma at ~80 @example blocks and calls CLAUDE.md's figure of 34 stale. Both numbers are counting artefacts:
| source | @example tags |
|---|---|
generated/ (Prisma's own client) |
47 |
index.spec.ts |
25 |
types.test-d.ts |
5 |
index.ts — the actual public API |
4 |
| total (the naive grep) | 81 |
The extractor reads the top level of src only and skips .spec. / .test-d. by name, so the surface it would actually guard is index.ts alone: 4 blocks, not ~80. The 34 in CLAUDE.md was the same artefact with generated/ excluded but the test files still counted.
That does not reverse the decision — it strengthens it. Prisma was picked as the highest-value target and the one that would expose what the generalisation needed; at 4 blocks it is neither.
What #216 did instead, and what it deliberately did not:
- Three private, tested
examples/*packages modelling one checkout domain (core,@unthrown/prisma,@unthrown/orpc), matching the convention already used inentity,temporal-contract,amqp-contractanddemesne. Real programs, compiled and tested, rather than extracted fragments. - The satellites' TSDoc
@exampleblocks remain unguarded. Core'sdoc-examples.spec.tsstill guards only core. That is an accepted trade-off, now recorded inCLAUDE.mdalongside the corrected count.
If guarding those blocks is still wanted later, it is a smaller job than this issue implied — and worth reopening with the real numbers.