Skip to content

docs: pnpm-workspace.yaml says @effect/docgen 0.5.2 drives the TS6 alias; it bundles TypeScript 5.5.2 #343

Closed

Description

@thomasfosterau

What's wrong

Three comments in pnpm-workspace.yaml say @effect/docgen drives TypeScript through the JS API and so "sees the TS6 side of the split". For the pinned docgen (^0.5.2, locked at 0.5.2) that is not true. docgen never loads the typescript package at all.

  • The catalog entry (lines 35–37): "Drives TypeScript through the JS API, so it sees the TS6 side of the split."
  • The typescript catalog entry (line 70) lists @effect/docgen among the JS-API consumers that "stay on TS6".
  • The "@effect/docgen>typescript": "6" peer rule (lines 151–153): "drives it through the JS API, which the TS6 alias above still provides".

Evidence

I checked npm pack @effect/docgen@0.5.2 in a fresh empty directory.

  • The package ships only bin.cjs (13.8 MB), package.json and schema.json. bin.cjs is an esbuild bundle that inlines ts-morph@23.0.0 together with @ts-morph/common@0.24.0/dist/typescript.js, which is TypeScript version = "5.5.2". It contains no require("typescript"). Its external requires are Node built-ins plus doctrine, glob, prettier and source-map-support. So docgen parses src/ with its own bundled TypeScript 5.5.2, under parseCompilerOptions.
  • runTscOnExamples spawns make("tsc", "--noEmit", "--project", <outDir>/examples/tsconfig.json). That is the tsc on PATH, which under vp run is the native TS7 tsc, as docs(AGENTS): say what vp run docgen runs and with which tsc #298 recorded.
  • runTsxOnExamples spawns tsx --tsconfig … <outDir>/examples/index.ts. That matches what the tsx catalog comment says.
  • handleImports → addAssertImport prepends import * as assert from 'assert' to any example containing assert.. scripts/docgen-class-examples.ts mirrors this. No src/ example uses assert. today.
  • To confirm at runtime, I ran node --require <hook> node_modules/@effect/docgen/bin.cjs on trunk, with a hook that logs every Module._load request matching typescript. Across a full successful run (24 modules, 226 examples), the only request was ./node_modules/@microsoft/typescript-etw, the bundled compiler's optional ETW probe. Nothing in the run resolved the typescript package.

So the typescript peer declared by docgen 0.5.2 (^5.2.2) is never used. The "@effect/docgen>typescript": "6" rule only quiets pnpm's peer-range check. It does not prove that TS6 works for docgen. In this repo the TS6 alias is loaded by scripts/docgen-class-examples.ts (import ts from "typescript"), the tsdown bundler and the language service, but not by docgen.

Proposed fix (this issue's PR)

This is a comment-only change to pnpm-workspace.yaml. The docgen version and the peer rule stay as they are. The rule is still needed while 0.5.x declares typescript ^5.2.2.

For the owner to decide: the docgen 4.x move pulpit made

pulpit moved to docgen 4.x in thomasfosterau/pulpit#97 (with #88/#96). The findings behind that move are in pulpit#62 and pulpit#8/#64. Checked against npm pack @effect/docgen@4.0.4:

  • It peers typescript >=5.8.2 <7.0.0 and tsx >=4.19.3 <5.0.0. The TS6 alias satisfies that range, so the "@effect/docgen>typescript" peer rule could be deleted.
  • It depends on ts-morph ^28 and tsconfck rather than bundling a compiler. It also adds a tscExecutable option.
  • It does not inject import * as assert. pulpit made its examples import assert explicitly by name.
  • runExamples defaults to false (type-check only). pulpit set "runExamples": true in docgen.json so its examples kept executing. Without that setting this repo's vp run docgen would silently stop running examples, and AGENTS.md's "executes your examples" section depends on them running.

scripts/docgen-class-examples.ts re-implements 0.5.2's pipeline (including the assert injection). It would need to be re-checked against 4.x, which may also collect class examples itself (#276, #288).

Also for the owner: AGENTS.md repeats the claim

AGENTS.md is the owner's file, so the PR leaves it untouched. The wording approved in #290 / #298 has the same inaccuracy:

  • Line 9: "TS6 … is only what the JS-API consumers — @effect/docgen's parse, …— load". docgen's parse uses its bundled TS 5.5.2.
  • Line 34: "Docgen parses src/ through the TypeScript JS API, so its parse sees the TS6 side of the split". The parse is through the bundled TS 5.5.2. The types: ["node"] rationale ("TypeScript 6 no longer auto-includes @types") still holds for examplesCompilerOptions (TS7). It does not hold for parseCompilerOptions (TS 5.5.2 still auto-includes), where the setting is harmless.

A possible line-34 wording: "Docgen 0.5.x parses src/ with its own bundled TypeScript 5.5.2 (via ts-morph), under parseCompilerOptions; it never loads the TS6 alias."

Done when

  • The pnpm-workspace.yaml comments describe what docgen 0.5.2 actually loads and spawns.
  • The owner decides on the 4.x move and on the AGENTS.md wording. Either can be split out.

Generated by Claude Code

Activity

  1. added
    documentation
    on Oct 15, 2026
  2. thomasfosterau commented on Oct 21, 2026

    @thomasfosterau
    OwnerAuthor

    Owner decision (2026-10-21): docgen is now on 4.0.5 (#222 merged). Bring the pnpm-workspace.yaml comments and AGENTS.md up to date for 4.x (AGENTS.md edits approved for this), and drop the @effect/docgen>typescript peer rule if 4.x's declared range admits the TS6 alias. #288 is folded in: check whether 4.x collects class/property examples itself, and either simplify scripts/docgen-class-examples.ts or extend it to property examples.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions