diff --git a/packages/run-protocol/src/vaultFactory/vaultDirector.js b/packages/run-protocol/src/vaultFactory/vaultDirector.js index 46087d8480a..3e628793992 100644 --- a/packages/run-protocol/src/vaultFactory/vaultDirector.js +++ b/packages/run-protocol/src/vaultFactory/vaultDirector.js @@ -263,7 +263,7 @@ const watchGovernance = (govParams, vaultManager, oldInstall, oldTerms) => { }); }; -/** @type {import('@agoric/vat-data/src/types').FunctionsPlusContext} */ +/** @type {import('@agoric/vat-data/src/types').FunctionsPlusContext} */ const machineBehavior = { // TODO move this under governance #3924 /** diff --git a/packages/vat-data/src/index.test-d.ts b/packages/vat-data/src/index.test-d.ts index 3a533e951f5..1e224a445d5 100644 --- a/packages/vat-data/src/index.test-d.ts +++ b/packages/vat-data/src/index.test-d.ts @@ -7,7 +7,12 @@ import { defineDurableKind, partialAssign, } from '.'; -import { KindFacets, DurableKindHandle, KindFacet } from './types.js'; +import { + KindFacets, + DurableKindHandle, + KindFacet, + FunctionsPlusContext, +} from './types.js'; /* export const makePaymentMaker = (allegedName: string, brand: unknown) => { @@ -140,3 +145,18 @@ partialAssign(state, { name: 'ed' }); partialAssign(state, { key: 'ted' }); // @ts-expect-error partialAssign(state, { name: 3 }); + +// test FunctionsPlusContext +type SomeFacet = { + gt(b: number): boolean; +}; +type SomeContext = { state: { a: number } }; +const someBehavior: FunctionsPlusContext = { + gt(context: SomeContext, b: number) { + return b > context.state.a; + }, +}; +const someFacet: KindFacet = null as any; +// @ts-expect-error +someFacet.gt(); +expectType(someFacet.gt(1)); diff --git a/packages/vat-data/src/types.d.ts b/packages/vat-data/src/types.d.ts index 159f1df1ab1..43c0b11ed24 100644 --- a/packages/vat-data/src/types.d.ts +++ b/packages/vat-data/src/types.d.ts @@ -32,7 +32,7 @@ type KindFacets = { type MultiKindContext = { state: S; facets: KindFacets }; type PlusContext = (c: C, ...args: Parameters) => ReturnType; -type FunctionsPlusContext = { [K in keyof O]: PlusContext }; +type FunctionsPlusContext = { [K in keyof O]: PlusContext }; declare class DurableKindHandleClass { private descriptionTag: string;