Repository navigation
chore: make docgen examples pass under @effect/docgen 0.5 and 4.x - #97
Merged
Merged
Conversation
Import `throws` from node:assert by name in the validateRegistry example instead of relying on docgen 0.5's injected `assert` namespace, which docgen 4.x no longer adds (the "Cannot find name 'assert'" failure on the effect-group bump). A named import compiles under both: 0.5 only injects when an example contains `assert.`, and a namespace import of our own would collide with that injection. Set `runExamples: true` in docgen.json: 0.5 always executed examples, 4.x only type-checks them unless asked to run. Part of #62 Claude-Session: https://claude.ai/code/session_01MbvVf1RHTwKCbEw9dyn3Aa Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Oct 14, 2026
This was referenced Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #62. This gets
trunkready for Dependabot #88 (effect 4.0.4,@effect/docgen0.5.2 → 4.0.4), so #88 goes green once it is rebased ontotrunk. The PR stays on docgen 0.5.2 and passes under both versions. #88 itself is not touched.Root cause of #88's red "Verify documentation examples (docgen)" step (
Cannot find name 'assert'at lines 24 and 31 of the generatedvalidateRegistryexample). Docgen 0.5.2'saddAssertImportprependsimport * as assert from 'assert'to any example whose text containsassert.(thebin.cjsofnpm pack @effect/docgen@0.5.2). Docgen 4.0.4'sCore.tshas no such injection.Changes:
packages/pulpit/src/registry.ts: thevalidateRegistryexample now doesimport { throws } from "node:assert"and callsthrows(…). It has to be a named import. A namespaceimport * as assert from "node:assert"fails under 0.5.2 withTS2300: Duplicate identifier 'assert', because it collides with the injected import (tested). With the named import, the example never containsassert., so 0.5.2 injects nothing, and 4.x has the import it needs.packages/pulpit/docgen.json: adds"runExamples": true. Docgen 0.5.2 always executed examples after type-checking them. Docgen 4.0.4 only type-checks them unlessrunExamplesis set (Config.Boolean("runExamples")defaults tofalse; its log says "Skipping running examples"). Without this setting, chore: Bump the effect group across 1 directory with 3 updates #88 would go green but would quietly stop executing examples. 0.5.2 ignores the key and always runs examples (verified in review:"runExamples": falsestill executes them), so nothing changes ontrunk. Until chore: Bump the effect group across 1 directory with 3 updates #88 lands, editors may flag the key against 0.5.2'sschema.json(additionalProperties: false); docgen itself accepts it.AGENTS.md: the@examplebullet no longer saysassert.…getsnode:assertimported for you. It now says to import assertion functions by name and explains why.Left for after #88 merges (owner decision on #62: follow-ups go in a separate PR), filed as #96:
"@effect/docgen>typescript": "6"frompeerDependencyRules, and its comment. On chore: Bump the effect group across 1 directory with 3 updates #88 + this PR with the entry removed,pnpm installleft the lockfile unchanged, and a cleanpnpm install --frozen-lockfileprinted no peer warning. 4.0.4'stypescript >=5.8.2 <7.0.0peer accepts the TS6 alias.@effect/docgencatalog comment. 4.x parses withts-morph+tsconfckand no longer uses a bundled TypeScript 5.5.src/". 4.x does no rewriting: the package name resolves through its ownexports, which point atsrc/.Verification
On this branch (
trunk+ this PR,@effect/docgen0.5.2), clean tree (rm -rf node_modules packages/*/node_modules tests/*/node_modules && pnpm install --frozen-lockfile):vp check: pass (0 errors; 46 warnings, all already ontrunk)vp run check: passvp run -r test:unit: passvp run -r build: passvp run -r docgen: pass (type-checks and runs the example)pnpm audit --audit-level high: pass (1 moderate, below the threshold)fallow audit --base origin/trunk: pass ("No issues in 3 changed files")fallow audit --format json --quiet --explain --gate-marker agent: verdictpassOn #88's head (
8fc4f55, docgen 4.0.4) with this PR cherry-picked on top (local only, not pushed):vp check,vp run check,vp run -r test:unit,vp run -r build,vp run -r docgen("Typechecking examples..." → "Running examples..." → "✓ Docs generation succeeded!") andpnpm audit --audit-level highall pass.Negative controls:
registry.tschange fails with exactly chore: Bump the effect group across 1 directory with 3 updates #88's CI errors ((24,1)and(31,1):error TS2304: Cannot find name 'assert').TypeErrorfailsvp run -r docgenwithAssertionError [ERR_ASSERTION]on both 0.5.2 and 4.0.4 (4.0.4 withrunExamples: true), which shows examples really are executed on both.Changeset
@example; the published package's behaviour is unchangedNotes
·@·d·ependabot r·ebaseon chore: Bump the effect group across 1 directory with 3 updates #88 triggers it (owner action).🤖 Generated with Claude Code
https://claude.ai/code/session_01MbvVf1RHTwKCbEw9dyn3Aa
Generated by Claude Code
Generated by Claude Code