Type the empty-input cases so tsc accepts the loop

The "neither series" test walks three inputs in one array literal. Inferred
from the literals alone, the bare `{}` widens to `{ HRV_RMSSD?: undefined }`,
and TypeScript rejects that against `pickHrvSummary`'s
`Record<string, DataSummary> | undefined` — an optional-undefined property is
not assignable to the index signature. Vitest never typechecks, so the suite
ran green while `tsc --noEmit` failed.

Annotating the array pins the parameter type at the declaration and leaves all
three cases exactly as they were.
This commit is contained in:
Antiheld86 committed 2026-09-03 07:03:54 +00:00
1 parent a165ff9bb6
commit 4594b664e3
1 file changed
+8 -1
@@ -91,7 +91,14 @@ describe("pickHrvSummary", () => {
// The tile is hidden either way; reporting the fallback type here would
// make an account with no HRV at all look like a ring user to the label
// and the freshness lookup.
for (const input of [undefined, {}, { HRV_RMSSD: summary(0, 0) }]) {
// Annotated: inferred from the literals alone, `{}` widens to
// `{ HRV_RMSSD?: undefined }`, which the index signature rejects.
const inputs: (Record<string, DataSummary> | undefined)[] = [
undefined,
{},
{ HRV_RMSSD: summary(0, 0) },
];
for (const input of inputs) {
const picked = pickHrvSummary(input);
expect((picked.summary?.count ?? 0) > 0).toBe(false);
expect(picked.type).toBe("HEART_RATE_VARIABILITY");