Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,11 @@ import type { CruxHistoryReport } from '@hugoer/web-perf-cli/crux-history';

Key exported types:

<!-- Adding a row here? Add the type to the `@typedef` block in lib/index.js and to both
the import and the `Rows` tuple in type-tests/root.ts, then run `npm run generate-types`.
lib/index.js is a value-only façade, so a type not re-declared there does not resolve
from the package root, and root.ts is the only guard that catches it. -->

| Type | Description |
|------|-------------|
| `LabReport` | Lighthouse JSON with `i18n` and `timing` stripped (categories, audits, environment, configSettings). Pass `--no-strip-json-props` / `stripJsonProps: false` to keep them |
Expand Down
4 changes: 4 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
*
* @typedef {import('./lab').LabReport} LabReport
* @typedef {import('./lab').LabPlanResult} LabPlanResult
* @typedef {import('./lab').LabAuditOptions} LabAuditOptions
* @typedef {import('./lab').LabWriteOptions} LabWriteOptions
* @typedef {import('./lab').LabPlanControls} LabPlanControls
* @typedef {import('./lab').LabPlanOptions} LabPlanOptions
* @typedef {import('./psi').PsiReport} PsiReport
* @typedef {import('./psi').PsiBatchResult} PsiBatchResult
* @typedef {import('./crux').CruxReport} CruxReport
Expand Down
7 changes: 6 additions & 1 deletion type-tests/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ import type {
CruxReport, CruxMetric, CruxBatchResult, CruxFormFactor,
CruxHistoryReport, CruxHistoryBatchResult, RunSummary,
LabProfile, NetworkPreset, DevicePreset,
LabAuditOptions, LabWriteOptions, LabPlanControls, LabPlanOptions,
} from '@hugoer/web-perf-cli';

export const fns = [runCruxAudit, runPsiAudit, runLabAudit, normalizeOrigin];
export const flags: readonly string[] = CHROME_FLAGS;

// Every row of the README's "Key exported types" table must resolve from the root.
// Every row of the README's "Key exported types" table must resolve from the root. The list is
// maintained by hand, so a new row added to that table is only covered once it is added here too
// — four Lab*Options rows sat undetected that way (#22). The README table carries a comment
// pointing back at this file so the two are edited together.
export type Rows = [
LabReport, LabPlanResult, PsiReport, PsiBatchResult,
CruxReport, CruxMetric, CruxBatchResult, CruxFormFactor,
CruxHistoryReport, CruxHistoryBatchResult, RunSummary,
LabProfile, NetworkPreset, DevicePreset,
LabAuditOptions, LabWriteOptions, LabPlanControls, LabPlanOptions,
];
26 changes: 25 additions & 1 deletion types/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare namespace _exports {
export { LabReport, LabPlanResult, PsiReport, PsiBatchResult, CruxReport, CruxMetric, CruxBatchResult, CruxFormFactor, CruxHistoryReport, CruxHistoryBatchResult, LabProfile, NetworkPreset, DevicePreset, RunSummary };
export { LabReport, LabPlanResult, LabAuditOptions, LabWriteOptions, LabPlanControls, LabPlanOptions, PsiReport, PsiBatchResult, CruxReport, CruxMetric, CruxBatchResult, CruxFormFactor, CruxHistoryReport, CruxHistoryBatchResult, LabProfile, NetworkPreset, DevicePreset, RunSummary };
}
declare namespace _exports {
const runLabAudit: typeof import("./lab").runLabAudit;
Expand Down Expand Up @@ -39,6 +39,30 @@ type LabReport = import("./lab").LabReport;
* documented `import type { CruxReport } from '@hugoer/web-perf-cli'` fails with TS2305.
*/
type LabPlanResult = import("./lab").LabPlanResult;
/**
* The types the README's "Key exported types" table promises from the package root. Re-declared
* here because lib/index.js is a value-only façade of lazy getters: without these, the
* documented `import type { CruxReport } from '@hugoer/web-perf-cli'` fails with TS2305.
*/
type LabAuditOptions = import("./lab").LabAuditOptions;
/**
* The types the README's "Key exported types" table promises from the package root. Re-declared
* here because lib/index.js is a value-only façade of lazy getters: without these, the
* documented `import type { CruxReport } from '@hugoer/web-perf-cli'` fails with TS2305.
*/
type LabWriteOptions = import("./lab").LabWriteOptions;
/**
* The types the README's "Key exported types" table promises from the package root. Re-declared
* here because lib/index.js is a value-only façade of lazy getters: without these, the
* documented `import type { CruxReport } from '@hugoer/web-perf-cli'` fails with TS2305.
*/
type LabPlanControls = import("./lab").LabPlanControls;
/**
* The types the README's "Key exported types" table promises from the package root. Re-declared
* here because lib/index.js is a value-only façade of lazy getters: without these, the
* documented `import type { CruxReport } from '@hugoer/web-perf-cli'` fails with TS2305.
*/
type LabPlanOptions = import("./lab").LabPlanOptions;
/**
* The types the README's "Key exported types" table promises from the package root. Re-declared
* here because lib/index.js is a value-only façade of lazy getters: without these, the
Expand Down