Skip to content

Commit

Permalink
fix(localchain): work around TypeScript mapped tuple bug
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jun 14, 2024
1 parent 40ccba1 commit 90e062c
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions packages/vats/src/localchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ const { Fail } = assert;
* @import {ScopedBridgeManager} from './types.js';
*/

/**
* @template {unknown[]} T
* @typedef {Promise<T>} PromiseVowOfTupleMappedToGenerics Temporary hack
*
* UNTIL(microsoft/TypeScript#57122): This type should be replaced with just
* PromiseVow<T>, but TypeScript doesn't understand that the result of a
* mapping a tuple type using generics is iterable:
*
* 'JsonSafe<MsgTransferResponse & { '@type':
* "/ibc.applications.transfer.v1.MsgTransferResponse"; }>[] |
* Vow<JsonSafe<MsgTransferResponse & { ...; }>[]>' must have a
* '[Symbol.iterator]()' method that returns an iterator.
*/

/**
* @typedef {{
* system: ScopedBridgeManager<'vlocalchain'>;
Expand Down Expand Up @@ -131,13 +145,15 @@ export const prepareLocalChainAccountKit = (zone, { watch }) =>
return E(purse).withdraw(amount);
},
/**
* Execute a batch of transactions and return the responses. Use
* `typedJson()` on the arguments to get typed return values.
* Execute a batch of messages in order as a single atomic transaction
* and return the responses. If any of the messages fails, the entire
* batch will be rolled back. Use `typedJson()` on the arguments to get
* typed return values.
*
* @template {TypedJson[]} MT messages tuple (use const with multiple
* elements or it will be a mixed array)
* @param {MT} messages
* @returns {PromiseVow<{
* @returns {PromiseVowOfTupleMappedToGenerics<{
* [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>>;
* }>}
*/
Expand Down

0 comments on commit 90e062c

Please sign in to comment.