Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(types): eschew ts-ignore #6575

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/SwingSet/src/controller/controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* global globalThis, WeakRef, FinalizationRegistry */
/* eslint-disable @typescript-eslint/prefer-ts-expect-error -- https://github.com/Agoric/agoric-sdk/issues/4620 */

import fs from 'fs';
import path from 'path';
Expand Down Expand Up @@ -287,9 +286,9 @@ export async function makeSwingsetController(
}

const bundles = [
// @ts-ignore assume lockdownBundle is set
// @ts-expect-error assume lockdownBundle is set
JSON.parse(kvStore.get('lockdownBundle')),
// @ts-ignore assume supervisorBundle is set
// @ts-expect-error assume supervisorBundle is set
JSON.parse(kvStore.get('supervisorBundle')),
];
const startXSnap = makeStartXSnap(bundles, {
Expand Down
4 changes: 0 additions & 4 deletions packages/SwingSet/src/kernel/kernelSyscall.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/prefer-ts-expect-error -- https://github.com/Agoric/agoric-sdk/issues/4620 */

import { assert, details as X } from '@agoric/assert';
import { insistKernelType } from './parseKernelSlots.js';
import { insistCapData } from '../lib/capdata.js';
Expand Down Expand Up @@ -207,10 +205,8 @@ export function makeKernelSyscallHandler(tools) {
workingLowerBound = actualLowerBound;
workingUpperBound = actualUpperBound;
workingKeyIterator = kvStore.getKeys(startKey, actualUpperBound);
// @ts-ignore some resolution thinks this is undefined
nextIter = workingKeyIterator.next();
if (!nextIter.done && nextIter.value === actualPriorKey) {
// @ts-ignore some resolution thinks this is undefined
nextIter = workingKeyIterator.next();
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/src/kernel/state/kernelKeeper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/prefer-ts-expect-error -- https://github.com/Agoric/agoric-sdk/issues/4620 */
import { Nat, isNat } from '@agoric/nat';
import { assert, details as X } from '@agoric/assert';
import { wrapStorage } from './storageWrapper.js';
Expand Down Expand Up @@ -215,7 +214,7 @@ export default function makeKernelKeeper(
*/
function getRequired(key) {
assert(kvStore.has(key), X`storage lacks required key ${key}`);
// @ts-ignore already checked .has()
// @ts-expect-error already checked .has()
return kvStore.get(key);
}

Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/src/lib/storageAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ export function makeBufferedStorage(kvStore, listeners = {}) {
if (additions.has(key)) return additions.get(key);
if (deletions.has(key)) return undefined;
const value = kvStore.get(key);
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error -- https://github.com/Agoric/agoric-sdk/issues/4620
// @ts-ignore value may be undefined
// @ts-expect-error value may be undefined
if (onGet !== undefined) onGet(key, value);
return value;
},
Expand Down
2 changes: 0 additions & 2 deletions packages/SwingSet/tools/prepare-test-env-ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import { wrapTest } from '@endo/ses-ava';
import rawTest from 'ava';

/** @type {typeof rawTest} */
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore XXX https://github.com/endojs/endo/issues/1235
export const test = wrapTest(rawTest);

// Does not import from a module because we're testing the global env
Expand Down
19 changes: 5 additions & 14 deletions packages/agoric-cli/src/lib/format.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
// @ts-check
/* eslint-disable @typescript-eslint/prefer-ts-expect-error -- https://github.com/Agoric/agoric-sdk/issues/4620 */
// eslint-disable-next-line no-unused-vars -- typeof below
import { makeAgoricNames } from './rpc.js';

// ambient types
import '@agoric/ertp/src/types-ambient.js';

/** @typedef {import('@agoric/smart-wallet/src/offers').OfferStatus} OfferStatus */

export const COSMOS_UNIT = 1_000_000n;

/**
Expand Down Expand Up @@ -97,13 +92,12 @@ export const fmtRecordOfLines = record => {
* Summarize the offerStatuses of the state as user-facing informative tuples
*
* @param {import('@agoric/smart-wallet/src/utils.js').CoalescedWalletState} state
* @param {Awaited<ReturnType<typeof makeAgoricNames>>} agoricNames
* @param {import('./rpc.js').AgoricNames} agoricNames
*/
export const offerStatusTuples = (state, agoricNames) => {
const { brands, offerStatuses } = state;
const fmt = makeAmountFormatter(
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error -- https://github.com/Agoric/agoric-sdk/issues/4620 */
// @ts-ignore xxx RpcRemote
// @ts-expect-error xxx RpcRemote
[...brands.values()],
);
const fmtRecord = r =>
Expand Down Expand Up @@ -136,7 +130,7 @@ export const offerStatusTuples = (state, agoricNames) => {
} = o;
// xxx could be O(1)
const entry = Object.entries(agoricNames.instance).find(
// @ts-ignore minimarshal types are off by a bit
// @ts-expect-error minimarshal types are off by a bit
([_name, candidate]) => candidate === instance,
);
const instanceName = entry ? entry[0] : '???';
Expand All @@ -159,17 +153,14 @@ export const offerStatusTuples = (state, agoricNames) => {
*
* @param {import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord} current
* @param {ReturnType<import('@agoric/smart-wallet/src/utils.js').makeWalletStateCoalescer>['state']} coalesced
* @param {Awaited<ReturnType<typeof makeAgoricNames>>} agoricNames
* @param {import('./rpc.js').AgoricNames} agoricNames
*/
export const summarize = (current, coalesced, agoricNames) => {
return {
lastOfferId: [current.lastOfferId],
purses: purseBalanceTuples(
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error -- https://github.com/Agoric/agoric-sdk/issues/4620 */
// @ts-ignore xxx RpcRemote
[...current.purses.values()],
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error -- https://github.com/Agoric/agoric-sdk/issues/4620 */
// @ts-ignore xxx RpcRemote
// @ts-expect-error xxx RpcRemote
[...current.brands.values()],
),
usedInvitations: Object.entries(current.offerToUsedInvitation).map(
Expand Down
1 change: 1 addition & 0 deletions packages/agoric-cli/src/lib/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,4 @@ export const makeRpcUtils = async ({ fetch }) => {

return { vstorage, fromBoard, agoricNames };
};
/** @typedef {Awaited<ReturnType<typeof makeAgoricNames>>} AgoricNames */
3 changes: 1 addition & 2 deletions packages/notifier/src/storesub.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ export const makeStoredSubscription = (
}

/** @type {StoredSubscription<T>} */
// eslint-disable-next-line -- different per package https://github.com/Agoric/agoric-sdk/issues/4620
// @ts-ignore getStoreKey type does not have `subscription`
// @ts-expect-error getStoreKey type does not have `subscription`
const storesub = Far('StoredSubscription', {
getStoreKey: async () => {
if (!storageNode) {
Expand Down
2 changes: 0 additions & 2 deletions packages/notifier/test/prepare-test-env-ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ import '@endo/init';
import { wrapTest } from '@endo/ses-ava';
import rawTest from 'ava';

// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore -- https://github.com/endojs/endo/issues/1235
export const test = wrapTest(rawTest);
12 changes: 5 additions & 7 deletions packages/notifier/test/test-publish-kit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/prefer-ts-expect-error -- https://github.com/Agoric/agoric-sdk/issues/4620 */

import { test } from './prepare-test-env-ava.js';
import {
makePublishKit,
Expand Down Expand Up @@ -124,13 +122,13 @@ test('makePublishKit', async t => {
'failure should not be allowed after finalization',
);
await t.throwsAsync(
// @ts-ignore known to be promise version of PublicationList
// @ts-expect-error known to be promise version of PublicationList
subFinal.tail,
undefined,
'tail promise of final result should be rejected',
);
await t.throwsAsync(
// @ts-ignore known to be promise version of PublicationList
// @ts-expect-error known to be promise version of PublicationList
subscriber.subscribeAfter(subFinal.publishCount),
undefined,
'subscribeAfter(finalPublishCount) should be rejected',
Expand Down Expand Up @@ -179,13 +177,13 @@ test('makePublishKit - immediate finish', async t => {
'failure should not be allowed after finalization',
);
await t.throwsAsync(
// @ts-ignore known to be promise version of PublicationList
// @ts-expect-error known to be promise version of PublicationList
subFinal.tail,
undefined,
'tail promise of final result should be rejected',
);
await t.throwsAsync(
// @ts-ignore known to be promise version of PublicationList
// @ts-expect-error known to be promise version of PublicationList
subscriber.subscribeAfter(subFinal.publishCount),
undefined,
'subscribeAfter(finalPublishCount) should be rejected',
Expand Down Expand Up @@ -336,7 +334,7 @@ test('subscribeAfter bounds checking', async t => {
const repr =
typeof badCount === 'string' ? JSON.stringify(badCount) : badCount;
t.throws(
// @ts-ignore deliberate invalid arguments for testing
// @ts-expect-error deliberate invalid arguments for testing
() => subscriber.subscribeAfter(badCount),
undefined,
`subscribeAfter should reject invalid publish count: ${typeof badCount} ${repr}`,
Expand Down
14 changes: 0 additions & 14 deletions packages/store/src/patterns/encodePassable.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,6 @@ const decodeTagged = (encoded, decodePassable) => {
* @param {EncodeOptions} [encodeOptions]
* @returns {(passable: Passable) => string}
*/
// `yarn lint` complains here but not for equivalent code in agoric-sdk.
// Also, vscode does not complain. Hence we're using at-ts-ignore rather than
// at-ts-expect-error. Using at-ts-ignore should also generate a complaint
// that we should be using at-expect-error, where we would normally need
// to suppress that error as well. However, perhaps that second error currently
// happens only in agoric-sdk, but not yet in endo. TODO figure out and fix.
// @ ts-ignore
export const makeEncodePassable = ({
encodeRemotable = (rem, _) => assert.fail(X`remotable unexpected: ${rem}`),
encodePromise = (prom, _) => assert.fail(X`promise unexpected: ${prom}`),
Expand Down Expand Up @@ -402,13 +395,6 @@ harden(makeEncodePassable);
* @param {DecodeOptions} [decodeOptions]
* @returns {(encoded: string) => Passable}
*/
// `yarn lint` complains here but not for equivalent code in agoric-sdk.
// Also, vscode does not complain. Hence we're using at-ts-ignore rather than
// at-ts-expect-error. Using at-ts-ignore should also generate a complaint
// that we should be using at-expect-error, where we would normally need
// to suppress that error as well. However, perhaps that second error currently
// happens only in agoric-sdk, but not yet in endo. TODO figure out and fix.
// @ ts-ignore
export const makeDecodePassable = ({
decodeRemotable = (rem, _) => assert.fail(X`remotable unexpected: ${rem}`),
decodePromise = (prom, _) => assert.fail(X`promise unexpected: ${prom}`),
Expand Down
6 changes: 2 additions & 4 deletions packages/store/src/patterns/interface-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ export const defineHeapFarClassKit = (
const contextMapKit = objectMap(methodsKit, () => new WeakMap());
const prototypeKit = objectMap(methodsKit, (methods, facetName) =>
defendPrototype(
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error -- different per package https://github.com/Agoric/agoric-sdk/issues/4620
// @ts-ignore could be symbol
// @ts-expect-error could be symbol
`${tag} ${facetName}`,
contextMapKit[facetName],
methods,
Expand Down Expand Up @@ -393,8 +392,7 @@ export const defineHeapFarClassKit = (
}
return facets;
};
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error -- different per package https://github.com/Agoric/agoric-sdk/issues/4620
// @ts-ignore xxx
// @ts-expect-error xxx
return harden(makeInstanceKit);
};
harden(defineHeapFarClassKit);
Expand Down
2 changes: 0 additions & 2 deletions packages/vat-data/src/far-class-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ export const vivifyFarInstance = (
options,
);

// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error -- https://github.com/Agoric/agoric-sdk/issues/4620
// @ts-ignore could be instantiated with an arbitrary type
return provide(baggage, `the_${kindName}`, () => makeSingleton());
};
harden(vivifyFarInstance);
Expand Down
2 changes: 0 additions & 2 deletions packages/web-components/src/AgoricWalletConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { html, css, LitElement } from 'lit';

import { assert, details as X } from '@agoric/assert';
import { makeCache } from '@agoric/cache';
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore
import { makeCapTP as defaultMakeCapTP } from '@endo/captp';
import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';
Expand Down