mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 06:06:10 +00:00
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:
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");
|
||||
|
||||
Reference in new issue
Block a user