Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
323 stars 204 forks source link

agoric/store types don't check #7507

Open turadg opened 1 year ago

turadg commented 1 year ago

Describe the bug

Most or all of the Store types don't report type errors because they're parameterized with any (Key and/or Passable which are defined as any)

Were this bug not present we would have avoided these bugs (partial list):

To Reproduce

For example,

  /** @type {SetStore<import('@agoric/vat-data').Baggage>} The set of baggages for zcfMints */
  const zcfMintBaggageSet = provideDurableSetStore(zcfBaggage, 'baggageSet');
  // @ts-expect-error but doesn't
  zcfMintBaggageSet.add(null);
*/

Expected behavior

Invalid type usage shows and error and fails CI

Additional context

Requires changes in Endo, including https://github.com/endojs/endo/issues/1488

dckc commented 1 year ago

@turadg you asked if we can do better than any as a typedef for passable. I did some relevant work in...

The .ts definition there is for OCapn value, but it's isomorphic to passable (with the exception that OCapn hasn't decided whether to distinguish promises from remotables). There's also an attempt at doing passable in .proto.

I think I did one in idris nearby, fwiw... Passable.idr https://github.com/ocapn/ocapn/issues/5#issuecomment-1478965669