fix(types): resolve the four Lab*Options types from the package root - #29
Merged
Conversation
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.
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.
Closes #22.
lib/index.jsis 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,LabPlanControlsandLabPlanOptionsreached the README's "Key exported types" table without the matching@typedef, so the import the README documents failed:The same import from
@hugoer/web-perf-cli/labworked 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.tsre-exports 18 types instead of 14 — additive, nothing removed or renamed. No runtime change: the diff tolib/is a JSDoc block and nothing else.Why the guard missed it
type-tests/root.tsopens 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
Rowsentries and the oldindex.js,check-typesreproduces exactly the fourTS2305errors 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.jsruns green against the working tree, confirming the export surface is intact.