From 4cd95d9bb33c2564db2ed39b99c2228cb9af67ac Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Wed, 10 Jan 2024 14:48:28 -0800 Subject: [PATCH] chore(types): misc accomodations --- packages/marshal/test/test-marshal-stringify.js | 2 ++ packages/patterns/src/keys/checkKey.js | 1 + packages/patterns/src/keys/copyBag.js | 1 + packages/patterns/src/keys/keycollection-operators.js | 3 +++ packages/patterns/src/keys/merge-bag-operators.js | 1 + 5 files changed, 8 insertions(+) diff --git a/packages/marshal/test/test-marshal-stringify.js b/packages/marshal/test/test-marshal-stringify.js index 4b33c9b302..3a0d2cdd3f 100644 --- a/packages/marshal/test/test-marshal-stringify.js +++ b/packages/marshal/test/test-marshal-stringify.js @@ -39,9 +39,11 @@ test('marshal stringify errors', t => { t.throws(() => stringify({}), { message: /Cannot pass non-frozen objects like .*. Use harden()/, }); + // @ts-expect-error intentional error t.throws(() => stringify(harden(new Uint8Array(1))), { message: 'Cannot pass mutable typed arrays like "[Uint8Array]".', }); + // @ts-expect-error intentional error t.throws(() => stringify(harden(new Int16Array(1))), { message: 'Cannot pass mutable typed arrays like "[Int16Array]".', }); diff --git a/packages/patterns/src/keys/checkKey.js b/packages/patterns/src/keys/checkKey.js index 7a50eb9a3b..4cdd2334c1 100644 --- a/packages/patterns/src/keys/checkKey.js +++ b/packages/patterns/src/keys/checkKey.js @@ -102,6 +102,7 @@ harden(assertScalarKey); // @ts-expect-error Key does not satisfy WeakKey /** @type {WeakSet} */ +// @ts-expect-error Key does not satisfy WeakKey const keyMemo = new WeakSet(); /** diff --git a/packages/patterns/src/keys/copyBag.js b/packages/patterns/src/keys/copyBag.js index 23be6278f8..9c09e7eef4 100644 --- a/packages/patterns/src/keys/copyBag.js +++ b/packages/patterns/src/keys/copyBag.js @@ -100,6 +100,7 @@ export const checkBagEntries = (bagEntries, check) => { ); } } + // @ts-expect-error FIXME Key types return checkNoDuplicateKeys(bagEntries, undefined, check); }; harden(checkBagEntries); diff --git a/packages/patterns/src/keys/keycollection-operators.js b/packages/patterns/src/keys/keycollection-operators.js index 8e2b46f465..75440a6761 100644 --- a/packages/patterns/src/keys/keycollection-operators.js +++ b/packages/patterns/src/keys/keycollection-operators.js @@ -27,6 +27,7 @@ const { quote: q, Fail } = assert; * @returns {IterableIterator<[import('../types.js').Key, V]>} */ const generateFullSortedEntries = (entries, rankCompare, fullCompare) => { + // @ts-expect-error FIXME Key types assertRankSorted(entries, rankCompare); const { length } = entries; let i = 0; @@ -56,8 +57,10 @@ const generateFullSortedEntries = (entries, rankCompare, fullCompare) => { // Sort the ties by `fullCompare`, enforce key uniqueness, and delegate to // a sub-iterator. + // @ts-expect-error FIXME Key types const sortedTies = sortByRank(ties, fullCompare); for (let k = 1; k < sortedTies.length; k += 1) { + // @ts-expect-error FIXME Key types const [key0] = sortedTies[k - 1]; const [key1] = sortedTies[k]; Math.sign(fullCompare(key0, key1)) || diff --git a/packages/patterns/src/keys/merge-bag-operators.js b/packages/patterns/src/keys/merge-bag-operators.js index 2ae5675f24..fdfb4901f5 100644 --- a/packages/patterns/src/keys/merge-bag-operators.js +++ b/packages/patterns/src/keys/merge-bag-operators.js @@ -72,6 +72,7 @@ const bagWindowResort = (bagEntries, rankCompare, fullCompare) => { // Providing the same `fullCompare` should cause a memo hit // within `assertNoDuplicates` enabling it to avoid a // redundant resorting. + // @ts-expect-error FIXME Key types assertNoDuplicateKeys(resorted, fullCompare); // This is the raw JS array iterator whose `.next()` method // does not harden the IteratorResult, in violation of our