Skip to content

Check exported TypeScript types for readers again, reading them with oxc - #2674

Merged
max-sixty merged 1 commit into
mainfrom
check-ts-type-exports
Oct 12, 2026
Merged

max-sixty merged 1 commit into
mainfrom
check-ts-type-exports

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

tests/js_facts.mjs (#2666) parsed TypeScript by blanking its types with amaro and handing the rest to acorn, so the unused-export check (tests/model/test_unused_exports.py) stopped seeing the 47 types and interfaces the TypeScript modules export. It now parses JavaScript and TypeScript alike with oxc-parser (new devDependency, 0.153.0, which shares @oxc-project/types with rolldown), which returns one ESTree for both, so those exports are checked like values again. One parse path serves every command; keydown derives its line from the node's offset, since oxc gives no loc. acorn and amaro stay in package.json for their other users.

Checking each newly read type against its real importers found one unused: Revision in build/browser/domain.ts, which only domain.ts uses and which the word search counted as read through the unrelated word "Revision" elsewhere. It loses its export. The other 46 each have an importer (a TypeScript import, a JSDoc import("…").Name, or a namespace import of the generated contract files).

No user-visible behaviour changes.

Checked: test_unused_exports.py, test_owner_index.py, and the test_interact_layer.py tests that call js_facts pass; adding an unread export interface to snapshot.ts fails the unused-export check; pnpm run check passes.

This was written by Claude Code on behalf of max-sixty

tests/js_facts.mjs parsed TypeScript by blanking its types with amaro and
handing the rest to acorn, so the unused-export check stopped seeing the 46
types and interfaces the TypeScript modules export. It now parses JavaScript
and TypeScript alike with oxc-parser, which returns one ESTree for both, so
those exports are checked like values again. acorn and amaro stay for their
other users.

Checking each newly read type against its real importers found one unused:
`Revision` in build/browser/domain.ts, which only domain.ts uses and which the
word search counted as read through the unrelated word "Revision" elsewhere.
It loses its `export`.

No user-visible behaviour changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit f81acdc into main Oct 12, 2026
4 checks passed
@max-sixty
max-sixty deleted the check-ts-type-exports branch October 12, 2026 21:53
max-sixty added a commit that referenced this pull request Oct 12, 2026
The unused-export check (`tests/model/test_unused_exports.py`) counted
an export as read wherever its name appeared as a word in any tracked
file, so an export used only in its own module passed whenever an
unrelated file shared the word. `Revision` in `build/browser/domain.ts`
passed that way for weeks (#2674).

`tests/js_facts.mjs` gains an `imports` reading that resolves each read
to the exporting file: named imports, re-exports, `export *` forwarding,
TypeScript and JSDoc `import("…").Name` types, and namespace use, static
or through `import()` (member reads, destructuring, `.then` handlers,
through `await`, conditionals and tests). It resolves extensionless and
`.js`-for-`.ts` specifiers, the served `/runtime/`, `/vendor/`,
`/widgets/` and `/checks/` paths, and a committed bundle compiled from
one module of this tree (`vendor/browser-runtime.js`) to that module.
Vendored bundles' own imports now count as readers, since what a bundle
left external is what it reads. A name taken from an `import()` of a
computed specifier reads that name in any module. The Worker's entry
(`worker/wrangler.toml`'s `main`) counts as read whole, since the
Workers runtime reads its exports by name (`ContainerProxy`). The word
search remains only for readers that are not JavaScript: Python tests,
pages and prose. The docstring names each of these readers.

The stricter check flagged three exports nothing reads:
`accompaniedThread` and `accompanyThread` in `thread/landing.js` and
`isAddressable` in `thread/model.js`. Reviewing the 77 exports that only
the word search still passes found three more that only share a word
with a reader: the `SAY_BOX` re-export in `thread/landing.js` (tests
read `thread/selectors.js`'s), `offerElement` in `widget-elements.js`,
and `generated` in `.github/scripts/dependency-bundles.mjs`. All six are
unexported or removed.

The served-path mapping `tests/runtime/dom.mjs` used moves to
`tests/served-paths.mjs`, which `js_facts.mjs` shares.

Restoring `export` on `isAddressable`, which `design.js` names because
it imports `anchor-resolution.js`'s, fails the new check and passes the
old one.

No user-visible behaviour changed.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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