fix(marshal): Fix typing for TS 4.5 compatibility
Make some types explicit any to prevent inference
MODIFY
packages/eventual-send/src/handled-promise.js
packages/eventual-send/src/handled-promise.js
@@ -427,7 +427,7 @@ export const makeHandledPromise = () => {
},
resolve(value) {
// Resolving a Presence returns the pre-registered handled promise.
- let resolvedPromise = presenceToPromise.get(value);
+ let resolvedPromise = presenceToPromise.get(/** @type {any} */ (value));
if (!resolvedPromise) {
resolvedPromise = Promise.resolve(value);
}

MODIFY
packages/marshal/src/dot-membrane.js
packages/marshal/src/dot-membrane.js
@@ -14,6 +14,8 @@ const { fromEntries } = Object;
const { ownKeys } = Reflect;
const { details: X } = assert;
+// TODO(erights): Add Converter type
+/** @param {any} [mirrorConverter] */
const makeConverter = (mirrorConverter = undefined) => {
/** @type {WeakMap<any,any>=} */
let mineToYours = new WeakMap();
@@ -61,6 +63,7 @@ const makeConverter = (mirrorConverter = undefined) => {
break;
}
case 'remotable': {
+ /** @param {PropertyKey} [optVerb] */
const myMethodToYours = (optVerb = undefined) => (...yourArgs) => {
// We use mineIf rather than mine so that mine is not accessible
// after revocation. This gives the correct error behavior,

MODIFY
packages/marshal/src/marshal-justin.js
packages/marshal/src/marshal-justin.js
@@ -396,7 +396,9 @@ const decodeToJustin = (encoding, shouldIndent = false) => {
return out.close(']');
}
} else {
- const names = ownKeys(rawTree);
+ // rawTree is an `EncodingRecord` which only has string keys,
+ // but since ownKeys is not generic, it can't propagate that
+ const names = /** @type {string[]} */ (ownKeys(rawTree));
if (names.length === 0) {
return out.next('{}');
} else {

MODIFY
packages/marshal/src/marshal.js
packages/marshal/src/marshal.js
@@ -451,6 +451,7 @@ export function makeMarshal(
default: {
assert(
+ // @ts-expect-error exhaustive check should make condition true
qclass !== 'ibid',
X`The protocol no longer supports ibid encoding: ${rawTree}.`,
);

MODIFY
packages/marshal/src/passStyleOf.js
packages/marshal/src/passStyleOf.js
@@ -15,21 +15,19 @@ import './types.js';
import './helpers/internal-types.js';
import { assertPassableSymbol } from './helpers/symbol.js';
+/** @typedef {Exclude<PassStyle, PrimitiveStyle | "promise">} HelperPassStyle */
+
const { details: X, quote: q } = assert;
const { ownKeys } = Reflect;
const { isFrozen } = Object;
/**
- * @param {PassStyleHelper[]} passStyleHelpers The passStyleHelpers to register,
- * in priority order.
- * NOTE These must all be "trusted",
- * complete, and non-colliding. `makePassStyleOf` may *assume* that each helper
- * does what it is supposed to do. `makePassStyleOf` is not trying to defend
- * itself against malicious helpers, though it does defend against some
- * accidents.
- * @returns {PassStyleOf}
+ * @param {PassStyleHelper[]} passStyleHelpers
+ * @returns {Record<HelperPassStyle, PassStyleHelper> }
*/
-const makePassStyleOf = passStyleHelpers => {
+
+const makeHelperTable = passStyleHelpers => {
+ /** @type {Record<HelperPassStyle, any> & {__proto__: null}} */
const HelperTable = {
__proto__: null,
copyArray: undefined,
@@ -54,7 +52,22 @@ const makePassStyleOf = passStyleHelpers => {
X`missing helper for ${q(styleName)}`,
);
}
- harden(HelperTable);
+
+ return harden(HelperTable);
+};
+
+/**
+ * @param {PassStyleHelper[]} passStyleHelpers The passStyleHelpers to register,
+ * in priority order.
+ * NOTE These must all be "trusted",
+ * complete, and non-colliding. `makePassStyleOf` may *assume* that each helper
+ * does what it is supposed to do. `makePassStyleOf` is not trying to defend
+ * itself against malicious helpers, though it does defend against some
+ * accidents.
+ * @returns {PassStyleOf}
+ */
+const makePassStyleOf = passStyleHelpers => {
+ const HelperTable = makeHelperTable(passStyleHelpers);
const remotableHelper = HelperTable.remotable;
/**

fix(marshal): Fix typing for TS 4.5 compatibility
Make some types explicit any to prevent inference