Skip to content

Commit

Permalink
fixes to get types building
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jan 10, 2024
1 parent caf606f commit 5baf106
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 23 deletions.
1 change: 1 addition & 0 deletions packages/marshal/src/rankOrder.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck FIXME before merge
import { getTag, passStyleOf, nameForPassableSymbol } from '@endo/pass-style';
import {
passStylePrefixes,
Expand Down
4 changes: 2 additions & 2 deletions packages/marshal/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ export {};
* ordering would also compare magnitudes, and so agree with the rank ordering
* of all values other than `NaN`. An array sorted by rank would enable range
* queries by magnitude.
* @param {Passable} left
* @param {Passable} right
* @param {import("@endo/pass-style").Passable} left
* @param {import("@endo/pass-style").Passable} right
* @returns {RankComparison}
*/

Expand Down
2 changes: 1 addition & 1 deletion packages/pass-style/src/makeTagged.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { Fail } = assert;

/**
* @template {string} T
* @template {any} P
* @template {import('./types.js').Passable} P
* @param {T} tag
* @param {P} payload
* @returns {import('./types.js').CopyTagged<T,P>}
Expand Down
16 changes: 8 additions & 8 deletions packages/pass-style/src/typeGuards.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const { Fail, quote: q } = assert;
* Check whether the argument is a pass-by-copy array, AKA a "copyArray"
* in @endo/marshal terms
*
* @param {unknown} arr
* @returns {arr is CopyArray<unknown>}
* @param {any} arr
* @returns {arr is CopyArray<any>}
*/
const isCopyArray = arr => passStyleOf(arr) === 'copyArray';
harden(isCopyArray);
Expand All @@ -27,8 +27,8 @@ harden(isCopyArray);
* Check whether the argument is a pass-by-copy record, AKA a
* "copyRecord" in @endo/marshal terms
*
* @param {unknown} record
* @returns {record is CopyRecord<unknown>}
* @param {any} record
* @returns {record is CopyRecord<any>}
*/
const isRecord = record => passStyleOf(record) === 'copyRecord';
harden(isRecord);
Expand All @@ -43,9 +43,9 @@ const isRemotable = remotable => passStyleOf(remotable) === 'remotable';
harden(isRemotable);

/**
* @param {unknown} array
* @param {any} array
* @param {string=} optNameOfArray
* @returns {asserts array is CopyArray<unknown>}
* @returns {asserts array is CopyArray<any>}
*/
const assertCopyArray = (array, optNameOfArray = 'Alleged array') => {
const passStyle = passStyleOf(array);
Expand All @@ -57,9 +57,9 @@ const assertCopyArray = (array, optNameOfArray = 'Alleged array') => {
harden(assertCopyArray);

/**
* @param {unknown} record
* @param {any} record
* @param {string=} optNameOfRecord
* @returns {asserts record is CopyRecord<unknown>}
* @returns {asserts record is CopyRecord<any>}
*/
const assertRecord = (record, optNameOfRecord = 'Alleged record') => {
const passStyle = passStyleOf(record);
Expand Down
7 changes: 6 additions & 1 deletion packages/pass-style/tools/arb-passable.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ const { arbDag } = fc.letrec(tie => {
),
}),
)
.map(({ type, payload }) => makeTagged(type, payload)),
.map(({ type, payload }) =>
makeTagged(
type,
/** @type {import('../src/types.js').Passable} */ (payload),
),
),
),
};
});
Expand Down
14 changes: 7 additions & 7 deletions packages/patterns/src/keys/checkKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const assertCopySet = s => {
harden(assertCopySet);

/**
* @template K
* @template {Key} K
* @param {CopySet<K>} s
* @returns {K[]}
*/
Expand All @@ -210,7 +210,7 @@ export const getCopySetKeys = s => {
harden(getCopySetKeys);

/**
* @template K
* @template {Key} K
* @param {CopySet<K>} s
* @param {(key: K, index: number) => boolean} fn
* @returns {boolean}
Expand All @@ -220,7 +220,7 @@ export const everyCopySetKey = (s, fn) =>
harden(everyCopySetKey);

/**
* @template K
* @template {Key} K
* @param {Iterable<K>} elementIter
* @returns {CopySet<K>}
*/
Expand Down Expand Up @@ -283,7 +283,7 @@ export const assertCopyBag = b => {
harden(assertCopyBag);

/**
* @template K
* @template {Key} K
* @param {CopyBag<K>} b
* @returns {CopyBag<K>['payload']}
*/
Expand All @@ -294,7 +294,7 @@ export const getCopyBagEntries = b => {
harden(getCopyBagEntries);

/**
* @template K
* @template {Key} K
* @param {CopyBag<K>} b
* @param {(entry: [K, bigint], index: number) => boolean} fn
* @returns {boolean}
Expand All @@ -304,7 +304,7 @@ export const everyCopyBagEntry = (b, fn) =>
harden(everyCopyBagEntry);

/**
* @template K
* @template {Key} K
* @param {Iterable<[K,bigint]>} bagEntryIter
* @returns {CopyBag<K>}
*/
Expand All @@ -316,7 +316,7 @@ export const makeCopyBag = bagEntryIter => {
harden(makeCopyBag);

/**
* @template K
* @template {Key} K
* @param {Iterable<K>} elementIter
* @returns {CopyBag<K>}
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/patterns/src/keys/copyBag.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const coerceToBagEntries = bagEntriesList => {
harden(coerceToBagEntries);

/**
* @template K
* @template {import('../types.js').Key} K
* @param {Iterable<[K, bigint]>} bagEntryIter
* @returns {CopyBag<K>}
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/patterns/src/keys/copySet.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const coerceToElements = elementsList => {
harden(coerceToElements);

/**
* @template K
* @template {import('../types.js').Key} K
* @param {Iterable<K>} elementIter
* @returns {CopySet<K>}
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/patterns/src/keys/merge-bag-operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const { quote: q, Fail } = assert;
* to `fullOrder`. However, it optimizes for the case where these contiguous
* runs that need to be resorted are either absent or small.
*
* @template T
* @template {import('../types').Passable} T
* @param {[T,bigint][]} bagEntries
* @param {RankCompare} rankCompare
* @param {FullCompare} fullCompare
Expand Down Expand Up @@ -96,7 +96,7 @@ const bagWindowResort = (bagEntries, rankCompare, fullCompare) => {
* For sets, these counts are always 0 or 1, but this representation
* generalizes nicely for bags.
*
* @template T
* @template {import('../types').Passable} T
* @param {[T,bigint][]} xbagEntries
* @param {[T,bigint][]} ybagEntries
* @returns {Iterable<[T,bigint,bigint]>}
Expand Down

0 comments on commit 5baf106

Please sign in to comment.