Skip to content

Commit

Permalink
fix(types): TypedMatcher --> TypedPattern
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jul 11, 2024
1 parent f10c9c1 commit 6b41829
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/auction/auctionBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {

const bookDataKit = makeRecorderKit(
node,
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<BookDataNotification>} */ (
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedPattern<BookDataNotification>} */ (
M.any()
),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/auction/auctioneer.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ export const start = async (zcf, privateArgs, baggage) => {
const scheduleKit = makeERecorderKit(
E(privateArgs.storageNode).makeChildNode('schedule'),
/**
* @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<
* @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedPattern<
* import('./scheduler.js').ScheduleNotification
* >}
*/ (M.any()),
Expand Down
4 changes: 2 additions & 2 deletions packages/inter-protocol/src/price/fluxAggregatorKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const prepareFluxAggregatorKit = async (
priceKit: () =>
makeRecorderKit(
storageNode,
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<PriceDescription>} */ (
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedPattern<PriceDescription>} */ (
M.any()
),
),
Expand All @@ -153,7 +153,7 @@ export const prepareFluxAggregatorKit = async (
makeRecorderKit(
node,
/**
* @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<
* @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedPattern<
* import('./roundsManager.js').LatestRound
* >}
*/ (M.any()),
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/psm/psm.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export const start = async (zcf, privateArgs, baggage) => {
E.when(E(privateArgs.storageNode).makeChildNode('metrics'), node =>
makeRecorderKit(
node,
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<MetricsNotification>} */ (
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedPattern<MetricsNotification>} */ (
M.any()
),
),
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/reserve/assetReserveKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const prepareAssetReserveKit = async (
keywordForBrand,
metricsKit: makeRecorderKit(
metricsNode,
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<MetricsNotification>} */ (
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedPattern<MetricsNotification>} */ (
M.any()
),
),
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/vaultFactory/vaultDirector.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const prepareVaultDirector = (

const metricsKit = makeERecorderKit(
metricsNode,
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<MetricsNotification>} */ (
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedPattern<MetricsNotification>} */ (
M.any()
),
);
Expand Down
17 changes: 7 additions & 10 deletions packages/zoe/src/contractSupport/recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export const prepareRecorder = (baggage, marshaller) => {
* @template T
* @param {PublishKit<T>['publisher']} publisher
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @param {TypedMatcher<T>} [valueShape]
* @param {TypedPattern<T>} [valueShape]
*/
(
publisher,
storageNode,
valueShape = /** @type {TypedMatcher<any>} */ (M.any()),
valueShape = /** @type {TypedPattern<any>} */ (M.any()),
) => {
return {
closed: false,
Expand Down Expand Up @@ -145,7 +145,7 @@ export const defineRecorderKit = ({ makeRecorder, makeDurablePublishKit }) => {
/**
* @template T
* @param {StorageNode | Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @param {TypedMatcher<T>} [valueShape]
* @param {TypedPattern<T>} [valueShape]
* @returns {RecorderKit<T>}
*/
const makeRecorderKit = (storageNode, valueShape) => {
Expand Down Expand Up @@ -174,7 +174,7 @@ export const defineERecorderKit = ({ makeRecorder, makeDurablePublishKit }) => {
/**
* @template T
* @param {ERef<StorageNode>} storageNodeP
* @param {TypedMatcher<T>} [valueShape]
* @param {TypedPattern<T>} [valueShape]
* @returns {EventualRecorderKit<T>}
*/
const makeERecorderKit = (storageNodeP, valueShape) => {
Expand Down Expand Up @@ -263,14 +263,11 @@ export const prepareMockRecorderKitMakers = () => {
* Stop-gap until https://github.com/Agoric/agoric-sdk/issues/6160
* explictly specify the type that the Pattern will verify through a match.
*
* This is a Pattern but since that's `any`, including in the typedef turns the
* whole thing to `any`.
*
* @template T
* @typedef {import('@endo/patterns').Matcher & { validatedType?: T }} TypedMatcher
* @typedef {import('@endo/patterns').Pattern & { validatedType?: T }} TypedPattern
*/

/**
* @template {TypedMatcher<any>} TM
* @typedef {TM extends TypedMatcher<infer T> ? T : never} MatchedType
* @template {TypedPattern<any>} TM
* @typedef {TM extends TypedPattern<infer T> ? T : never} MatchedType
*/

0 comments on commit 6b41829

Please sign in to comment.