diff --git a/packages/ERTP/jsconfig.json b/packages/ERTP/jsconfig.json index a952d3509ba..d2e659dcc2d 100644 --- a/packages/ERTP/jsconfig.json +++ b/packages/ERTP/jsconfig.json @@ -6,6 +6,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", "types": [ "node" diff --git a/packages/SwingSet/jsconfig.json b/packages/SwingSet/jsconfig.json index 81a97c09978..6e3990d52d7 100644 --- a/packages/SwingSet/jsconfig.json +++ b/packages/SwingSet/jsconfig.json @@ -6,6 +6,7 @@ "checkJs": true, "noEmit": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/SwingSet/src/lib-nodejs/worker-protocol.js b/packages/SwingSet/src/lib-nodejs/worker-protocol.js index dea9027dc6d..260b9940507 100644 --- a/packages/SwingSet/src/lib-nodejs/worker-protocol.js +++ b/packages/SwingSet/src/lib-nodejs/worker-protocol.js @@ -7,6 +7,7 @@ import { Transform } from 'stream'; export function arrayEncoderStream() { /** * + * @this {{ push: (b: Buffer) => void }} * @param {*} object * @param {BufferEncoding} encoding * @param {*} callback @@ -30,6 +31,7 @@ export function arrayEncoderStream() { export function arrayDecoderStream() { /** * + * @this {{ push: (b: Buffer) => void }} * @param {Buffer} buf * @param {BufferEncoding} encoding * @param {*} callback diff --git a/packages/SwingSet/src/lib/netstring.js b/packages/SwingSet/src/lib/netstring.js index 45142303c91..6bb4d2f5001 100644 --- a/packages/SwingSet/src/lib/netstring.js +++ b/packages/SwingSet/src/lib/netstring.js @@ -22,6 +22,7 @@ export function encode(data) { export function netstringEncoderStream() { /** * + * @this {{ push: (b: Buffer) => void }} * @param {Buffer} chunk * @param {BufferEncoding} encoding * @param {*} callback @@ -86,6 +87,7 @@ export function netstringDecoderStream(optMaxChunkSize) { let buffered = Buffer.from(''); /** * + * @this {{ push: (b: Buffer) => void }} * @param {Buffer} chunk * @param {BufferEncoding} encoding * @param {*} callback diff --git a/packages/access-token/jsconfig.json b/packages/access-token/jsconfig.json index 20b970a3dd1..5eb6e745dfa 100644 --- a/packages/access-token/jsconfig.json +++ b/packages/access-token/jsconfig.json @@ -12,6 +12,7 @@ */ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/agoric-cli/jsconfig.json b/packages/agoric-cli/jsconfig.json index e386c8555f4..641beb64699 100644 --- a/packages/agoric-cli/jsconfig.json +++ b/packages/agoric-cli/jsconfig.json @@ -13,6 +13,7 @@ */ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/agoric-cli/src/commands/oracle.js b/packages/agoric-cli/src/commands/oracle.js index 3578b045fcf..86166d6b2ff 100644 --- a/packages/agoric-cli/src/commands/oracle.js +++ b/packages/agoric-cli/src/commands/oracle.js @@ -69,6 +69,7 @@ export const makeOracleCommand = async logger => { ) .option('--offerId [number]', 'Offer id', Number, Date.now()) .action(async function () { + // @ts-expect-error this implicit any const opts = this.opts(); const instance = lookupPriceAggregatorInstance(opts.pair); @@ -104,6 +105,7 @@ export const makeOracleCommand = async logger => { ) .requiredOption('--price [number]', 'price (format TODO)', String) .action(async function () { + // @ts-expect-error this implicit any const opts = this.opts(); /** @type {import('../lib/psm.js').OfferSpec} */ @@ -136,6 +138,7 @@ export const makeOracleCommand = async logger => { ['ATOM', 'USD'], ) .action(async function () { + // @ts-expect-error this implicit any const { pair } = this.opts(); const capDataStr = await vstorage.readLatest( diff --git a/packages/agoric-cli/src/commands/perf.js b/packages/agoric-cli/src/commands/perf.js index c06aadbbe9b..efba4c05855 100644 --- a/packages/agoric-cli/src/commands/perf.js +++ b/packages/agoric-cli/src/commands/perf.js @@ -45,6 +45,7 @@ export const makePerfCommand = async logger => { ) .option('--home [string]', 'directory for config and data') .action(async function () { + // @ts-expect-error this implicit any const opts = this.opts(); logger.warn({ opts }); const payloadStr = await fs.readFileSync(opts.executeOffer).toString(); diff --git a/packages/agoric-cli/src/commands/psm.js b/packages/agoric-cli/src/commands/psm.js index 8e96b431077..f20a176fdbf 100644 --- a/packages/agoric-cli/src/commands/psm.js +++ b/packages/agoric-cli/src/commands/psm.js @@ -126,6 +126,7 @@ export const makePsmCommand = async logger => { ['IST', 'AUSD'], ) .action(async function () { + // @ts-expect-error this implicit any const { pair } = this.opts(); const { governance } = await getGovernanceState(pair); console.log('psm governance params', Object.keys(governance)); @@ -159,6 +160,7 @@ export const makePsmCommand = async logger => { .option('--feePct [%]', 'Gas fee percentage', Number) .option('--offerId [number]', 'Offer id', Number, Date.now()) .action(async function () { + // @ts-expect-error this implicit any const opts = this.opts(); console.warn('running with options', opts); const instance = await lookupPsmInstance(opts.pair); @@ -172,6 +174,7 @@ export const makePsmCommand = async logger => { .description('join the economic committee') .option('--offerId [number]', 'Offer id', Number, Date.now()) .action(async function () { + // @ts-expect-error this implicit any const opts = this.opts(); const { economicCommittee } = agoricNames.instance; @@ -202,6 +205,7 @@ export const makePsmCommand = async logger => { .description('prepare an offer to accept the charter invitation') .option('--offerId [number]', 'Offer id', Number, Date.now()) .action(async function () { + // @ts-expect-error this implicit any const opts = this.opts(); const { psmCharter } = agoricNames.instance; @@ -255,6 +259,7 @@ export const makePsmCommand = async logger => { 1, ) .action(async function () { + // @ts-expect-error this implicit any const opts = this.opts(); const psmInstance = lookupPsmInstance(opts.pair); @@ -312,6 +317,7 @@ export const makePsmCommand = async logger => { 1, ) .action(async function () { + // @ts-expect-error this implicit any const opts = this.opts(); const psmInstance = lookupPsmInstance(opts.pair); @@ -366,6 +372,7 @@ export const makePsmCommand = async logger => { Number, ) .action(async function () { + // @ts-expect-error this implicit any const opts = this.opts(); const questionHandleCapDataStr = await vstorage.readLatest( diff --git a/packages/agoric-cli/src/commands/wallet.js b/packages/agoric-cli/src/commands/wallet.js index 62fea897697..3fcfd2e22dc 100644 --- a/packages/agoric-cli/src/commands/wallet.js +++ b/packages/agoric-cli/src/commands/wallet.js @@ -53,6 +53,7 @@ export const makeWalletCommand = async () => { spend, home, keyringBackend: backend, + // @ts-expect-error this implicit any } = this.opts(); const tx = `provision-one ${nickname} ${account} SMART_WALLET`; if (spend) { @@ -102,6 +103,7 @@ export const makeWalletCommand = async () => { offer, home, keyringBackend: backend, + // @ts-expect-error this implicit any } = this.opts(); execSwingsetTransaction( @@ -131,6 +133,7 @@ export const makeWalletCommand = async () => { normalizeAddress, ) .action(async function () { + // @ts-expect-error this implicit any const opts = this.opts(); const { agoricNames, fromBoard, vstorage } = await makeRpcUtils({ @@ -176,6 +179,7 @@ export const makeWalletCommand = async () => { normalizeAddress, ) .action(async function () { + // @ts-expect-error this implicit any const { from } = this.opts(); const spec = `:published.wallet.${from}`; diff --git a/packages/assert/jsconfig.json b/packages/assert/jsconfig.json index 5b49fdf922e..c427eff5cfb 100644 --- a/packages/assert/jsconfig.json +++ b/packages/assert/jsconfig.json @@ -3,9 +3,8 @@ "compilerOptions": { "target": "esnext", "module": "esnext", - "noEmit": true, -/* + /* // The following flags are for creating .d.ts files: "noEmit": false, "declaration": true, @@ -13,6 +12,7 @@ */ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/cache/jsconfig.json b/packages/cache/jsconfig.json index 574efb7853d..c0220e6dd95 100644 --- a/packages/cache/jsconfig.json +++ b/packages/cache/jsconfig.json @@ -7,6 +7,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/casting/jsconfig.json b/packages/casting/jsconfig.json index 574efb7853d..c0220e6dd95 100644 --- a/packages/casting/jsconfig.json +++ b/packages/casting/jsconfig.json @@ -7,6 +7,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/cosmic-proto/tsconfig.json b/packages/cosmic-proto/tsconfig.json index 88079b96a95..0e93484c29e 100644 --- a/packages/cosmic-proto/tsconfig.json +++ b/packages/cosmic-proto/tsconfig.json @@ -7,6 +7,7 @@ "allowSyntheticDefaultImports": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", "outDir": "dist" }, diff --git a/packages/cosmic-swingset/jsconfig.json b/packages/cosmic-swingset/jsconfig.json index 1ea05b00f4c..8c6d9976bf4 100644 --- a/packages/cosmic-swingset/jsconfig.json +++ b/packages/cosmic-swingset/jsconfig.json @@ -12,6 +12,7 @@ */ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/deploy-script-support/jsconfig.json b/packages/deploy-script-support/jsconfig.json index 6de2c49ef46..1bc5745423f 100644 --- a/packages/deploy-script-support/jsconfig.json +++ b/packages/deploy-script-support/jsconfig.json @@ -7,6 +7,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/deployment/jsconfig.json b/packages/deployment/jsconfig.json index 20b970a3dd1..5eb6e745dfa 100644 --- a/packages/deployment/jsconfig.json +++ b/packages/deployment/jsconfig.json @@ -12,6 +12,7 @@ */ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/governance/jsconfig.json b/packages/governance/jsconfig.json index 858ad6a85b1..242b11f4bbb 100644 --- a/packages/governance/jsconfig.json +++ b/packages/governance/jsconfig.json @@ -6,6 +6,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/inter-protocol/jsconfig.json b/packages/inter-protocol/jsconfig.json index a6d0d34134e..dc34fe095bf 100644 --- a/packages/inter-protocol/jsconfig.json +++ b/packages/inter-protocol/jsconfig.json @@ -7,6 +7,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/internal/jsconfig.json b/packages/internal/jsconfig.json index 37469ecb668..cf1e13ca5ce 100644 --- a/packages/internal/jsconfig.json +++ b/packages/internal/jsconfig.json @@ -7,6 +7,7 @@ "downlevelIteration": true, "noImplicitAny": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", "types": [ "node" diff --git a/packages/notifier/jsconfig.json b/packages/notifier/jsconfig.json index f0ab26f7584..1635d0e0d5e 100644 --- a/packages/notifier/jsconfig.json +++ b/packages/notifier/jsconfig.json @@ -7,6 +7,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/pegasus/jsconfig.json b/packages/pegasus/jsconfig.json index 0f3b5a4bfc9..f54cbf215f6 100644 --- a/packages/pegasus/jsconfig.json +++ b/packages/pegasus/jsconfig.json @@ -3,9 +3,8 @@ "compilerOptions": { "target": "esnext", "module": "esnext", - "noEmit": true, -/* + /* // The following flags are for creating .d.ts files: "noEmit": false, "declaration": true, @@ -13,6 +12,7 @@ */ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/smart-wallet/jsconfig.json b/packages/smart-wallet/jsconfig.json index 92298f10852..c5ba4d5cace 100644 --- a/packages/smart-wallet/jsconfig.json +++ b/packages/smart-wallet/jsconfig.json @@ -6,6 +6,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/smart-wallet/src/smartWallet.js b/packages/smart-wallet/src/smartWallet.js index 4810758a09d..c1e17a1844c 100644 --- a/packages/smart-wallet/src/smartWallet.js +++ b/packages/smart-wallet/src/smartWallet.js @@ -232,9 +232,8 @@ const behaviorGuards = { const behavior = { helper: { /** - * @this {{ state: State, facets: typeof behavior }} * @param {RemotePurse} purse - * @param {Amount} balance + * @param {Amount} balance * @param {'init'} [init] */ updateBalance(purse, balance, init) { @@ -252,9 +251,6 @@ const behavior = { helper.publishCurrentState(); }, - /** - * @this {{ state: State, facets: typeof behavior }} - */ publishCurrentState() { const { brandDescriptors, @@ -275,7 +271,6 @@ const behavior = { /** @type {(desc: Omit, purse: RemotePurse) => Promise} */ async addBrand(desc, purseRef) { - /** @type {State} */ const { address, brandDescriptors, @@ -332,10 +327,7 @@ const behavior = { const payments = paymentQueues.has(desc.brand) ? paymentQueues.get(desc.brand) : []; - const deposits = payments.map(p => - // @ts-expect-error deposit does take a FarRef - E(purse).deposit(p), - ); + const deposits = payments.map(p => E(purse).deposit(p)); Promise.all(deposits).catch(err => console.error('ERROR depositing queued payments', err), ); @@ -350,11 +342,11 @@ const behavior = { * * If the purse doesn't exist, we hold the payment until it does. * + * @this {SmartWalletThis} * @param {import('@endo/far').FarRef} payment * @returns {Promise} amounts for deferred deposits will be empty */ async receive(payment) { - /** @type {State} */ const { brandPurses, paymentQueues: queues } = this.state; const brand = await E(payment).getAllegedBrand(); @@ -385,13 +377,13 @@ const behavior = { /** * Take an offer description provided in capData, augment it with payments and call zoe.offer() * + * @this {SmartWalletThis} * @param {import('./offers.js').OfferSpec} offerSpec * @returns {Promise} when the offer has been sent to Zoe; payouts go into this wallet's purses * @throws if any parts of the offer can be determined synchronously to be invalid */ async executeOffer(offerSpec) { const { facets } = this; - /** @type {State} */ const { address, zoe, @@ -443,6 +435,7 @@ const behavior = { self: { /** * + * @this {SmartWalletThis} * @param {import('@endo/marshal').CapData} actionCapData of type BridgeAction * @param {boolean} [canSpend=false] * @returns {Promise} @@ -465,29 +458,33 @@ const behavior = { }, ); }, - /** @returns {SmartWalletBehavior['deposit']} */ + /** @this {SmartWalletThis} */ getDepositFacet() { return this.facets.deposit; }, - /** @returns {SmartWalletBehavior['offers']} */ + /** @this {SmartWalletThis} */ getOffersFacet() { return this.facets.offers; }, - /** @returns {StoredSubscriber} */ + /** @this {SmartWalletThis} */ getCurrentSubscriber() { return this.state.currentPublishKit.subscriber; }, - /** @returns {StoredSubscriber} */ + /** @this {SmartWalletThis} */ getUpdatesSubscriber() { - /** @type {{state: State}} */ - // @ts-expect-error - const { state } = this; - return state.updatePublishKit.subscriber; + return this.state.updatePublishKit.subscriber; }, }, }; /** @typedef {typeof behavior} SmartWalletBehavior */ +// XXX defineVirtualFarClassKit should infer this +/** @typedef {{ facets: SmartWalletBehavior, state: State }} SmartWalletThis */ +// TODO type facets (runs into problems with 'this') +/** + * + * @param {{ state: State, facets: * }} param0 + */ const finish = ({ state, facets }) => { /** @type {State} */ const { invitationBrand, invitationIssuer, invitationPurse, bank } = state; diff --git a/packages/solo/jsconfig.json b/packages/solo/jsconfig.json index 51992bfe6ff..35c0b15aadd 100644 --- a/packages/solo/jsconfig.json +++ b/packages/solo/jsconfig.json @@ -12,6 +12,7 @@ */ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/sparse-ints/jsconfig.json b/packages/sparse-ints/jsconfig.json index 20b970a3dd1..5eb6e745dfa 100644 --- a/packages/sparse-ints/jsconfig.json +++ b/packages/sparse-ints/jsconfig.json @@ -12,6 +12,7 @@ */ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/stat-logger/jsconfig.json b/packages/stat-logger/jsconfig.json index 20b970a3dd1..5eb6e745dfa 100644 --- a/packages/stat-logger/jsconfig.json +++ b/packages/stat-logger/jsconfig.json @@ -12,6 +12,7 @@ */ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/store/jsconfig.json b/packages/store/jsconfig.json index f49e23ca966..f05b5057347 100644 --- a/packages/store/jsconfig.json +++ b/packages/store/jsconfig.json @@ -7,6 +7,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/store/src/patterns/interface-tools.js b/packages/store/src/patterns/interface-tools.js index e7340c48caa..931ef0a6d03 100644 --- a/packages/store/src/patterns/interface-tools.js +++ b/packages/store/src/patterns/interface-tools.js @@ -137,7 +137,7 @@ const defendMethod = (method, methodGuard, label) => { * * @param {string} methodTag * @param {WeakMap} contextMap - * @param {Method} behaviorMethod + * @param {CallableFunction} behaviorMethod * @param {boolean} [thisfulMethods] * @param {MethodGuard} [methodGuard] */ @@ -195,7 +195,7 @@ const bindMethod = ( }; /** - * @template {Record} T + * @template {Record} T * @param {string} tag * @param {WeakMap} contextMap * @param {T} behaviorMethods @@ -280,13 +280,13 @@ export const initEmpty = () => emptyRecord; */ /** - * @template A - * @template S - * @template {{}} T + * @template A args to init + * @template S state from init + * @template {Record} T methods * @param {string} tag * @param {any} interfaceGuard * @param {(...args: A[]) => S} init - * @param {T} methods + * @param {T & ThisType} methods * @param {object} [options] * @returns {(...args: A[]) => (T & import('@endo/eventual-send').RemotableBrand<{}, T>)} */ @@ -330,13 +330,13 @@ export const defineHeapFarClass = ( harden(defineHeapFarClass); /** - * @template A - * @template S - * @template {Record} F + * @template A args to init + * @template S state from init + * @template {Record>} F methods * @param {string} tag * @param {any} interfaceGuardKit * @param {(...args: A[]) => S} init - * @param {F} methodsKit + * @param {F & { [K in keyof F]: ThisType }} methodsKit * @param {object} [options] * @returns {(...args: A[]) => F} */ diff --git a/packages/store/test/test-heap-classes.js b/packages/store/test/test-heap-classes.js index a9c92663721..a8c99ca6cdf 100644 --- a/packages/store/test/test-heap-classes.js +++ b/packages/store/test/test-heap-classes.js @@ -24,10 +24,10 @@ test('test defineHeapFarClass', t => { const makeUpCounter = defineHeapFarClass( 'UpCounter', UpCounterI, + /** @param {number} x */ (x = 0) => ({ x }), { incr(y = 1) { - // @ts-expect-error TS doesn't know that `this` is a `Context` const { state } = this; state.x += y; return state.x; @@ -51,11 +51,11 @@ test('test defineHeapFarClassKit', t => { const makeCounterKit = defineHeapFarClassKit( 'Counter', { up: UpCounterI, down: DownCounterI }, + /** @param {number} x */ (x = 0) => ({ x }), { up: { incr(y = 1) { - // @ts-expect-error xxx this.state const { state } = this; state.x += y; return state.x; @@ -63,7 +63,6 @@ test('test defineHeapFarClassKit', t => { }, down: { decr(y = 1) { - // @ts-expect-error xxx this.state const { state } = this; state.x -= y; return state.x; diff --git a/packages/swing-store/jsconfig.json b/packages/swing-store/jsconfig.json index ccb9a505c7c..30cb7b373db 100644 --- a/packages/swing-store/jsconfig.json +++ b/packages/swing-store/jsconfig.json @@ -11,6 +11,7 @@ "emitDeclarationOnly": true, */ "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/swingset-runner/jsconfig.json b/packages/swingset-runner/jsconfig.json index 3c39b292fd6..4ce8d1400d2 100644 --- a/packages/swingset-runner/jsconfig.json +++ b/packages/swingset-runner/jsconfig.json @@ -7,6 +7,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/telemetry/jsconfig.json b/packages/telemetry/jsconfig.json index 4bbf8dfc50c..d8f08ac74d1 100644 --- a/packages/telemetry/jsconfig.json +++ b/packages/telemetry/jsconfig.json @@ -7,6 +7,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/ui-components/jsconfig.json b/packages/ui-components/jsconfig.json index 58a8c8a9324..68bf2bb305a 100644 --- a/packages/ui-components/jsconfig.json +++ b/packages/ui-components/jsconfig.json @@ -3,9 +3,8 @@ "compilerOptions": { "target": "esnext", "module": "esnext", - "noEmit": true, -/* + /* // The following flags are for creating .d.ts files: "noEmit": false, "declaration": true, @@ -13,6 +12,7 @@ */ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", "jsx": "react", }, diff --git a/packages/vat-data/src/far-class-utils.js b/packages/vat-data/src/far-class-utils.js index 515c0317d90..a3ddfd79ddd 100644 --- a/packages/vat-data/src/far-class-utils.js +++ b/packages/vat-data/src/far-class-utils.js @@ -45,11 +45,13 @@ harden(defineVirtualFarClass); // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206 /** - * @template A,S,T + * @template A args to init + * @template S state from init + * @template {Record>} T facets * @param {string} tag * @param {any} interfaceGuardKit * @param {(...args: A[]) => S} init - * @param {T} facets + * @param {T & { [K in keyof T]: ThisType }} facets * @param {DefineKindOptions} [options] * @returns {(...args: A[]) => (T & RemotableBrand<{}, T>)} */ @@ -71,11 +73,13 @@ harden(defineVirtualFarClassKit); // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206 /** - * @template A,S,T + * @template A args to init + * @template S state from init + * @template {Record} T methods * @param {DurableKindHandle} kindHandle * @param {any} interfaceGuard * @param {(...args: A[]) => S} init - * @param {T} methods + * @param {T & ThisType} methods * @param {DefineKindOptions} [options] * @returns {(...args: A[]) => (T & RemotableBrand<{}, T>)} */ @@ -97,11 +101,13 @@ harden(defineDurableFarClass); // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206 /** - * @template A,S,T + * @template A args to init + * @template S state from init + * @template {Record>} T facets * @param {DurableKindHandle} kindHandle * @param {any} interfaceGuardKit * @param {(...args: A[]) => S} init - * @param {T} facets + * @param {T & { [K in keyof T]: ThisType }} facets * @param {DefineKindOptions} [options] * @returns {(...args: A[]) => (T & RemotableBrand<{}, T>)} */ @@ -123,12 +129,14 @@ harden(defineDurableFarClassKit); // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206 /** - * @template A,S,T + * @template A args to init + * @template S state from init + * @template {Record} T methods * @param {Baggage} baggage * @param {string} kindName * @param {any} interfaceGuard * @param {(...args: A[]) => S} init - * @param {T} methods + * @param {T & ThisType} methods * @param {DefineKindOptions} [options] * @returns {(...args: A[]) => (T & RemotableBrand<{}, T>)} */ @@ -151,12 +159,14 @@ harden(vivifyFarClass); // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206 /** - * @template A,S,T + * @template A args to init + * @template S state from init + * @template {Record>} T facets * @param {Baggage} baggage * @param {string} kindName * @param {any} interfaceGuardKit * @param {(...args: A[]) => S} init - * @param {T} facets + * @param {T & { [K in keyof T]: ThisType }} facets * @param {DefineKindOptions} [options] * @returns {(...args: A[]) => (T & RemotableBrand<{}, T>)} */ @@ -179,7 +189,8 @@ harden(vivifyFarClassKit); // TODO interfaceGuard type https://github.com/Agoric/agoric-sdk/issues/6206 /** - * @template T,M + * @template T + * @template {Record} M methods * @param {Baggage} baggage * @param {string} kindName * @param {any} interfaceGuard @@ -211,7 +222,7 @@ harden(vivifyFarInstance); /** * @deprecated Use vivifyFarInstance instead. - * @template T + * @template {Record} T methods * @param {Baggage} baggage * @param {string} kindName * @param {T} methods diff --git a/packages/vat-data/test/test-durable-classes.js b/packages/vat-data/test/test-durable-classes.js index 230962e1196..0509ade09da 100644 --- a/packages/vat-data/test/test-durable-classes.js +++ b/packages/vat-data/test/test-durable-classes.js @@ -28,10 +28,10 @@ test('test defineDurableFarClass', t => { const makeUpCounter = defineDurableFarClass( upCounterKind, UpCounterI, + /** @param {number} x */ (x = 0) => ({ x }), { incr(y = 1) { - // @ts-expect-error TS doesn't know that `this` is a `Context` const { state } = this; state.x += y; return state.x; @@ -87,6 +87,7 @@ test('test defineDurableFarClassKit', t => { message: 'In "decr" method of (Counter down) arg 0: string "foo" - Must be a number', }); + // @ts-expect-error the type violation is what we're testing t.throws(() => upCounter.decr(3), { message: 'upCounter.decr is not a function', }); diff --git a/packages/vat-data/test/test-virtual-classes.js b/packages/vat-data/test/test-virtual-classes.js index b8b199e8efa..d4015cc126f 100644 --- a/packages/vat-data/test/test-virtual-classes.js +++ b/packages/vat-data/test/test-virtual-classes.js @@ -82,6 +82,7 @@ test('test defineVirtualFarClassKit', t => { message: 'In "decr" method of (Counter down) arg 0: string "foo" - Must be a number', }); + // @ts-expect-error the type violation is what we're testing t.throws(() => upCounter.decr(3), { message: 'upCounter.decr is not a function', }); diff --git a/packages/vat-data/test/test-vivify.js b/packages/vat-data/test/test-vivify.js index c82b9d8e150..8b8090eb860 100644 --- a/packages/vat-data/test/test-vivify.js +++ b/packages/vat-data/test/test-vivify.js @@ -33,7 +33,6 @@ test('test vivifyFarClass', t => { (x = 0) => ({ x }), { incr(y = 1) { - // @ts-expect-error TS doesn't know that `this` is a `Context` const { state } = this; state.x += y; return state.x; @@ -90,6 +89,7 @@ test('test vivifyFarClassKit', t => { message: 'In "decr" method of (Counter down) arg 0: string "foo" - Must be a number', }); + // @ts-expect-error the type violation is what we're testing t.throws(() => upCounter.decr(3), { message: 'upCounter.decr is not a function', }); diff --git a/packages/vats/jsconfig.json b/packages/vats/jsconfig.json index fc0786fb00d..9f590bf1928 100644 --- a/packages/vats/jsconfig.json +++ b/packages/vats/jsconfig.json @@ -5,6 +5,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/wallet/api/jsconfig.json b/packages/wallet/api/jsconfig.json index 0f3b5a4bfc9..1e3864ec1d2 100644 --- a/packages/wallet/api/jsconfig.json +++ b/packages/wallet/api/jsconfig.json @@ -3,16 +3,10 @@ "compilerOptions": { "target": "esnext", "module": "esnext", - "noEmit": true, -/* - // The following flags are for creating .d.ts files: - "noEmit": false, - "declaration": true, - "emitDeclarationOnly": true, -*/ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/web-components/jsconfig.json b/packages/web-components/jsconfig.json index 5a183cba851..022b6f00d70 100644 --- a/packages/web-components/jsconfig.json +++ b/packages/web-components/jsconfig.json @@ -3,9 +3,8 @@ "compilerOptions": { "target": "esnext", "module": "esnext", - "noEmit": true, -/* + /* // The following flags are for creating .d.ts files: "noEmit": false, "declaration": true, @@ -13,6 +12,7 @@ */ "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/zoe/jsconfig.json b/packages/zoe/jsconfig.json index df25dccaf78..b778899ba5e 100644 --- a/packages/zoe/jsconfig.json +++ b/packages/zoe/jsconfig.json @@ -6,6 +6,7 @@ "noEmit": true, "downlevelIteration": true, "strictNullChecks": true, + "noImplicitThis": true, "moduleResolution": "node", }, "include": [ diff --git a/packages/zoe/test/swingsetTests/upgradeCoveredCall/coveredCall-durable-V3.js b/packages/zoe/test/swingsetTests/upgradeCoveredCall/coveredCall-durable-V3.js index a4c6c847e76..41fd30ca40b 100644 --- a/packages/zoe/test/swingsetTests/upgradeCoveredCall/coveredCall-durable-V3.js +++ b/packages/zoe/test/swingsetTests/upgradeCoveredCall/coveredCall-durable-V3.js @@ -39,7 +39,6 @@ const vivify = async (zcf, _privateArgs, instanceBaggage) => { sellSeat => ({ sellSeat }), { handle(buySeat) { - // @ts-expect-error TS doesn't understand context const { state } = this; assert(!state.sellSeat.hasExited(), sellSeatExpiredMsg); try {