Skip to content

fix(types): resolve the four Lab*Options types from the package root - #29

Merged
Hugoer merged 2 commits into
mainfrom
fix/root-lab-options-types
Sep 4, 2026
Merged

fix(types): resolve the four Lab*Options types from the package root#29
Hugoer merged 2 commits into
mainfrom
fix/root-lab-options-types

Conversation

@Hugoer

@Hugoer Hugoer commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Closes #22.

lib/index.js is a value-only façade of lazy getters, so a type resolves from the package root only if it is re-declared there. LabAuditOptions, LabWriteOptions, LabPlanControls and LabPlanOptions reached the README's "Key exported types" table without the matching @typedef, so the import the README documents failed:

error TS2305: Module '"@hugoer/web-perf-cli"' has no exported member 'LabAuditOptions'.

The same import from @hugoer/web-perf-cli/lab worked throughout, so this affected only consumers following the README's root-import form.

Behaviour change

The four types now resolve from the package root. types/lib/index.d.ts re-exports 18 types instead of 14 — additive, nothing removed or renamed. No runtime change: the diff to lib/ is a JSDoc block and nothing else.

Why the guard missed it

type-tests/root.ts opens by asserting that every row of the README table resolves from the root, then enumerates the rows by hand — and these four were never listed. It passed on an invariant it only partially checked.

Verified the guard is load-bearing rather than vacuous: with the new Rows entries and the old index.js, check-types reproduces exactly the four TS2305 errors from the issue; with both, it passes.

On the drift itself

The issue left open whether to solve the hand-maintained list. This PR takes the cheap option — an HTML comment above the README table naming the two files to edit alongside it. Generating the check (parsing the table at test time) would actually close the hole, but the blast radius here is a documented type that does not resolve, not a broken build, and a Markdown parser in the test path costs more than the drift. Worth revisiting if it drifts a third time.

Verification

npm run lint, npm test (594 passed), npm run generate-types, npm run check-types — all pass. examples/crux-audit.js runs green against the working tree, confirming the export surface is intact.

lib/index.js is a value-only façade of lazy getters, so a type is importable
from the root only if it is re-declared there. LabAuditOptions, LabWriteOptions,
LabPlanControls and LabPlanOptions were added to the README's "Key exported
types" table without the matching @typedef, so the documented
`import type { LabPlanOptions } from '@hugoer/web-perf-cli'` failed with TS2305
while the same import from the /lab subpath worked.

type-tests/root.ts asserts that every row of that table resolves from the root,
but enumerates the rows by hand and never listed these four, so the guard passed
on an invariant it only partially checked. Adding them to the import and the Rows
tuple reproduces the four TS2305 errors against the old index.js and passes
against the new one.

Same defect #17 fixed for LabReport, CruxReport and the rest.
The hand-maintained Rows tuple in type-tests/root.ts is why the four Lab*Options
rows drifted undetected: a README row added without a matching tuple entry is
invisible to CI. An HTML comment above the table names the two files to edit
alongside it and why the root re-declaration is needed at all.

A comment rather than a generated check: the failure mode is a documented type
that does not resolve, not a broken build, and parsing the table at test time
costs more than the drift it would prevent. Revisit if it drifts again.
@Hugoer
Hugoer merged commit ccdd9e0 into main Sep 4, 2026
6 checks passed
@Hugoer
Hugoer deleted the fix/root-lab-options-types branch September 4, 2026 09:39
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.

Four README-documented types do not resolve from the package root

1 participant