Skip to content

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

Description

@Hugoer

type-tests/root.ts opens with the invariant it exists to hold:

Every row of the README's "Key exported types" table must resolve from the root.

Four rows do not. Adding them to that file fails:

type-tests/root.ts(22,15): error TS2305: Module '"@hugoer/web-perf-cli"' has no exported member 'LabAuditOptions'.
type-tests/root.ts(22,32): error TS2305: Module '"@hugoer/web-perf-cli"' has no exported member 'LabWriteOptions'.
type-tests/root.ts(22,49): error TS2305: Module '"@hugoer/web-perf-cli"' has no exported member 'LabPlanControls'.
type-tests/root.ts(22,66): error TS2305: Module '"@hugoer/web-perf-cli"' has no exported member 'LabPlanOptions'.

This is the same defect #17 fixed for LabReport, CruxReport and the rest:
lib/index.js is a value-only façade of lazy getters, so a type is only
importable from the root if it is re-declared there. The four Lab*Options rows
were added to the README table without the matching @typedef in lib/index.js.

The guard did not catch it because root.ts enumerates the rows by hand, and
these four were never added to the list — so the file asserts an invariant it
only partially checks.

Fix

  1. Re-declare the four in lib/index.js alongside the existing typedefs.
  2. Add them to both the import and the Rows tuple in type-tests/root.ts.
  3. Regenerate types/.

Worth deciding

The hand-maintained list in root.ts is the reason this drifted silently, and it
will drift again — the next README row added without a tuple entry is invisible.
Whether that is worth solving (a generated list, or a comment in the README table
pointing at the guard) is the open question; the three-step fix above is correct
either way.

Found while working #20, which added LabProfile, NetworkPreset and
DevicePreset to the same table and wired all three through both places.

Activity

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions