Skip to content

Commit ff7a2f8

Browse files
committed
🚨 Sort through a copy, so the Node typecheck accepts the History proofs (#881)
`tsconfig.node.json` pins `lib` to ES2022 and `toSorted` is ES2023, so the three `toSorted` calls in the History suite failed `tsc` in every `test-node` shard before a single test ran — ten identical shard failures, and the `green` gate with them. `deno check`, `deno task test` and `pnpm lint` all passed, and oxlint's `no-array-sort` actively recommends `toSorted`, so nothing local said otherwise. Sort a copy instead, which keeps what `toSorted` was chosen for: `ordinals` arrives `readonly`, and nothing observes the order of the array sorted here. `Object.keys` already returns a fresh array, so that one sorts in place. The three remaining `no-array-sort` warnings are the lib's cost, and the comment at the first site says so.
1 parent a9905f3 commit ff7a2f8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎packages/cli/tests/repl-history.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ describe("H4 — the five rows are allocated by measurement", () => {
171171
const members = first.value.groups.flatMap((one) => one.ordinals);
172172
expect(members.length).toBe(40);
173173
expect(new Set(members).size).toBe(40);
174-
expect(members.toSorted((a, b) => a - b)).toEqual(
174+
// Sorted through a copy rather than with `toSorted`: the Node
175+
// typecheck's `lib` is ES2022, and `toSorted` is ES2023.
176+
expect([...members].sort((a, b) => a - b)).toEqual(
175177
Array.from({ length: 40 }, (_, at) => at + 1),
176178
);
177179
}));
@@ -423,7 +425,7 @@ describe("H3 — the head a real session publishes", () => {
423425
yield* sleep(0);
424426
expect(JSON.stringify(session.navigation)).not.toContain("shibboleth");
425427
for (const point of session.navigation.checkpoints) {
426-
expect(Object.keys(point).toSorted()).toEqual(["kind", "marker"]);
428+
expect(Object.keys(point).sort()).toEqual(["kind", "marker"]);
427429
}
428430
});
429431
});
@@ -590,7 +592,7 @@ describe("H1 — two positions the rail draws as one mark select different conte
590592
}
591593
const pairs = rail.value.groups
592594
.flatMap((group) => {
593-
const ordinals = group.ordinals.toSorted((a, b) => a - b);
595+
const ordinals = [...group.ordinals].sort((a, b) => a - b);
594596
return ordinals.flatMap((ordinal, at) =>
595597
at + 1 < ordinals.length && ordinals[at + 1] === ordinal + 1
596598
? [[ordinal, ordinal + 1] as const]

0 commit comments

Comments
 (0)