Skip to content

Commit

Permalink
refactor: Make all TS import extensions explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Nov 11, 2023
1 parent c5620c8 commit 7b43ada
Show file tree
Hide file tree
Showing 147 changed files with 366 additions and 364 deletions.
2 changes: 1 addition & 1 deletion packages/SwingSet/src/controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export async function makeSwingsetController(
warehousePolicy,
overrideVatManagerOptions,
};
/** @type { ReturnType<typeof import('../kernel').default> } */
/** @type { ReturnType<typeof import('../kernel.js').default> } */
const kernel = buildKernel(
kernelEndowments,
deviceEndowments,
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/controller/startXSnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function makeStartXSnap(options) {
};
}

/** @type { import('@agoric/xsnap/src/xsnap').XSnapOptions } */
/** @type { import('@agoric/xsnap/src/xsnap.js').XSnapOptions } */
const xsnapOpts = {
os: osType(),
fs: { ...fs, ...fs.promises, tmpName },
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/vat-warehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export function makeVatWarehouse({
// console.debug('makeVatWarehouse', { warehousePolicy });

/**
* @typedef { ReturnType<typeof import('./vatTranslator').makeVatTranslators> } VatTranslators
* @typedef { ReturnType<typeof import('./vatTranslator.js').makeVatTranslators> } VatTranslators
* @typedef {{
* manager: VatManager,
* translators: VatTranslators,
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/src/types-external.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export {};
* @typedef { DeviceInvocationResultOk | DeviceInvocationResultError } DeviceInvocationResult
*
* @typedef { { transcriptCount: number } } VatStats
* @typedef { ReturnType<typeof import('./kernel/state/vatKeeper').makeVatKeeper> } VatKeeper
* @typedef { ReturnType<typeof import('./kernel/state/kernelKeeper').default> } KernelKeeper
* @typedef { ReturnType<typeof import('./kernel/state/vatKeeper.js').makeVatKeeper> } VatKeeper
* @typedef { ReturnType<typeof import('./kernel/state/kernelKeeper.js').default> } KernelKeeper
* @typedef { Awaited<ReturnType<typeof import('@agoric/xsnap').xsnap>> } XSnap
* @typedef { (dr: VatDeliveryResult) => void } SlogFinishDelivery
* @typedef { (ksr: KernelSyscallResult, vsr: VatSyscallResult) => void } SlogFinishSyscall
Expand Down
12 changes: 6 additions & 6 deletions packages/SwingSet/src/vats/timer/vat-timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import { TimeMath } from '@agoric/time';
// client). Everything else should remain in the DB.

/**
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
* @typedef {import('@agoric/time/src/types').TimestampRecord} TimestampRecord
* @typedef {import('@agoric/time/src/types').TimestampValue} TimestampValue
* @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
* @typedef {import('@agoric/time/src/types').RelativeTimeValue} RelativeTimeValue
* @typedef {import('@agoric/time/src/types').TimerService} TimerService
* @typedef {import('@agoric/time/src/types.js').Timestamp} Timestamp
* @typedef {import('@agoric/time/src/types.js').TimestampRecord} TimestampRecord
* @typedef {import('@agoric/time/src/types.js').TimestampValue} TimestampValue
* @typedef {import('@agoric/time/src/types.js').RelativeTime} RelativeTime
* @typedef {import('@agoric/time/src/types.js').RelativeTimeValue} RelativeTimeValue
* @typedef {import('@agoric/time/src/types.js').TimerService} TimerService
*
* @typedef {object} Handler
* Handler is a user-provided Far object with .wake(time) used for callbacks
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/tools/manual-timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { TimeMath } from '@agoric/time';
import { buildRootObject } from '../src/vats/timer/vat-timer.js';

/**
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
* @typedef {import('@agoric/time/src/types').TimerService} TimerService
* @typedef {import('@agoric/time/src/types.js').Timestamp} Timestamp
* @typedef {import('@agoric/time/src/types.js').TimerService} TimerService
* @typedef {import('../src/devices/timer/device-timer.js').Waker} Waker
*
* @typedef {object} ManualTimerCallbacks
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const makeAuctionCommand = (
* but TimeMath.toRel prodocues a RelativeTime (which may be a bare bigint).
*
* @param {bigint} relValue
* @returns {import('@agoric/time/src/types').RelativeTimeRecord}
* @returns {import('@agoric/time/src/types.js').RelativeTimeRecord}
*/
const toRel = relValue => ({ timerBrand, relValue });

Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/gov.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const makeGovCommand = (_logger, io = {}) => {
* given a sendFrom address; else print it.
*
* @param {{
* toOffer: (agoricNames: *, current: import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord | undefined) => OfferSpec,
* toOffer: (agoricNames: *, current: import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord | undefined) => OfferSpec,
* sendFrom?: string | undefined,
* keyringBackend: string,
* instanceName?: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/inter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const bidInvitationShape = harden({
});

/** @typedef {import('@agoric/vats/tools/board-utils.js').VBankAssetDetail } AssetDescriptor */
/** @typedef {import('@agoric/smart-wallet/src/smartWallet').TryExitOfferAction } TryExitOfferAction */
/** @typedef {import('@agoric/smart-wallet/src/smartWallet.js').TryExitOfferAction } TryExitOfferAction */
/** @typedef {import('@agoric/inter-protocol/src/auction/auctionBook.js').OfferSpec} BidSpec */
/** @typedef {import('@agoric/inter-protocol/src/auction/scheduler.js').ScheduleNotification} ScheduleNotification */
/** @typedef {import('@agoric/inter-protocol/src/auction/auctionBook.js').BookDataNotification} BookDataNotification */
Expand Down
6 changes: 3 additions & 3 deletions packages/agoric-cli/src/lib/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ harden(normalizeAddressWithOptions);

/**
* @param {ReadonlyArray<string>} swingsetArgs
* @param {import('./rpc').MinimalNetworkConfig & {
* @param {import('./rpc.js').MinimalNetworkConfig & {
* from: string,
* fees?: string,
* dryRun?: boolean,
Expand Down Expand Up @@ -110,7 +110,7 @@ export const fetchSwingsetParams = net => {
harden(fetchSwingsetParams);

/**
* @param {import('./rpc').MinimalNetworkConfig & {
* @param {import('./rpc.js').MinimalNetworkConfig & {
* execFileSync: typeof import('child_process').execFileSync,
* delay: (ms: number) => Promise<void>,
* period?: number,
Expand Down Expand Up @@ -150,7 +150,7 @@ export const pollBlocks = opts => async lookup => {

/**
* @param {string} txhash
* @param {import('./rpc').MinimalNetworkConfig & {
* @param {import('./rpc.js').MinimalNetworkConfig & {
* execFileSync: typeof import('child_process').execFileSync,
* delay: (ms: number) => Promise<void>,
* period?: number,
Expand Down
4 changes: 2 additions & 2 deletions packages/agoric-cli/src/lib/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const asBoardRemote = x => {
/**
* Summarize the balances array as user-facing informative tuples
*
* @param {import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord['purses']} purses
* @param {import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord['purses']} purses
* @param {AssetDescriptor[]} assets
*/
export const purseBalanceTuples = (purses, assets) => {
Expand Down Expand Up @@ -172,7 +172,7 @@ export const offerStatusTuples = (state, agoricNames) => {
};

/**
* @param {import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord} current
* @param {import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord} current
* @param {ReturnType<import('@agoric/smart-wallet/src/utils.js').makeWalletStateCoalescer>['state']} coalesced
* @param {import('./wallet.js').AgoricNamesRemotes} agoricNames
*/
Expand Down
18 changes: 9 additions & 9 deletions packages/agoric-cli/src/lib/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const emptyCurrentRecord = {
/**
* @param {string} addr
* @param {Pick<import('./rpc.js').RpcUtils, 'readLatestHead'>} io
* @returns {Promise<import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord>}
* @returns {Promise<import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord>}
*/
export const getCurrent = async (addr, { readLatestHead }) => {
// Partial because older writes may not have had all properties
// NB: assumes changes are only additions
let current =
/** @type {Partial<import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord> | undefined} */ (
/** @type {Partial<import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord> | undefined} */ (
await readLatestHead(`published.wallet.${addr}.current`)
);
if (current === undefined) {
Expand Down Expand Up @@ -58,15 +58,15 @@ export const getCurrent = async (addr, { readLatestHead }) => {
/**
* @param {string} addr
* @param {Pick<import('./rpc.js').RpcUtils, 'readLatestHead'>} io
* @returns {Promise<import('@agoric/smart-wallet/src/smartWallet').UpdateRecord>}
* @returns {Promise<import('@agoric/smart-wallet/src/smartWallet.js').UpdateRecord>}
*/
export const getLastUpdate = (addr, { readLatestHead }) => {
// @ts-expect-error cast
return readLatestHead(`published.wallet.${addr}`);
};

/**
* @param {import('@agoric/smart-wallet/src/smartWallet').BridgeAction} bridgeAction
* @param {import('@agoric/smart-wallet/src/smartWallet.js').BridgeAction} bridgeAction
* @param {Pick<import('stream').Writable,'write'>} [stdout]
*/
export const outputAction = (bridgeAction, stdout = process.stdout) => {
Expand All @@ -79,7 +79,7 @@ const sendHint =
'Now use `agoric wallet send ...` to sign and broadcast the offer.\n';

/**
* @param {import('@agoric/smart-wallet/src/smartWallet').BridgeAction} bridgeAction
* @param {import('@agoric/smart-wallet/src/smartWallet.js').BridgeAction} bridgeAction
* @param {{
* stdout: Pick<import('stream').Writable,'write'>,
* stderr: Pick<import('stream').Writable,'write'>,
Expand All @@ -95,7 +95,7 @@ export const outputActionAndHint = (bridgeAction, { stdout, stderr }) => {
* @param {Pick<import('stream').Writable,'write'>} [stdout]
*/
export const outputExecuteOfferAction = (offer, stdout = process.stdout) => {
/** @type {import('@agoric/smart-wallet/src/smartWallet').BridgeAction} */
/** @type {import('@agoric/smart-wallet/src/smartWallet.js').BridgeAction} */
const spendAction = {
method: 'executeOffer',
offer,
Expand All @@ -105,7 +105,7 @@ export const outputExecuteOfferAction = (offer, stdout = process.stdout) => {

/**
* @deprecated use `.current` node for current state
* @param {import('@agoric/casting').Follower<import('@agoric/casting').ValueFollowerElement<import('@agoric/smart-wallet/src/smartWallet').UpdateRecord>>} follower
* @param {import('@agoric/casting').Follower<import('@agoric/casting').ValueFollowerElement<import('@agoric/smart-wallet/src/smartWallet.js').UpdateRecord>>} follower
* @param {Brand<'set'>} [invitationBrand]
*/
export const coalesceWalletState = async (follower, invitationBrand) => {
Expand All @@ -128,8 +128,8 @@ export const coalesceWalletState = async (follower, invitationBrand) => {
* Sign and broadcast a wallet-action.
*
* @throws { Error & { code: number } } if transaction fails
* @param {import('@agoric/smart-wallet/src/smartWallet').BridgeAction} bridgeAction
* @param {import('./rpc').MinimalNetworkConfig & {
* @param {import('@agoric/smart-wallet/src/smartWallet.js').BridgeAction} bridgeAction
* @param {import('./rpc.js').MinimalNetworkConfig & {
* from: string,
* fees?: string,
* verbose?: boolean,
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const makeLookup =
/**
* @param {string[]} scripts
* @param {{ allowUnsafePlugins: boolean, progname: string, rawArgs: string[], endowments?: Record<string, any> }} opts
* @param {{ fs: import('fs/promises'), console: Console }} powers
* @param {{ fs: import('fs/promises.js'), console: Console }} powers
*/
export const makeScriptLoader =
(
Expand Down
4 changes: 2 additions & 2 deletions packages/base-zone/tools/testers.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const secondThrows = (t, fn, spec = alreadyExceptionSpec) => {

/**
* @param {import('ava').Assertions} t
* @param {import('../src/index').Zone} rootZone
* @param {import('../src/index.js').Zone} rootZone
*/
export const testFirstZoneIncarnation = (t, rootZone) => {
const subZone = secondThrows(t, () => rootZone.subZone('sub'));
Expand Down Expand Up @@ -94,7 +94,7 @@ export const testFirstZoneIncarnation = (t, rootZone) => {

/**
* @param {import('ava').Assertions} t
* @param {import('../src/index').Zone} rootZone
* @param {import('../src/index.js').Zone} rootZone
*/
export const testSecondZoneIncarnation = (t, rootZone) => {
const subZone = secondThrows(t, () => rootZone.subZone('sub'));
Expand Down
6 changes: 3 additions & 3 deletions packages/boot/tools/authorityViz.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ const { Fail, quote: q } = assert;
* @param {string} specifier
* @param {object} io
* @param {Resolver} io.resolve
* @param {typeof import('fs/promises').readFile} io.readFile
* @param {typeof import('fs/promises.js').readFile} io.readFile
*/
const loadConfig = async (specifier, { resolve, readFile }) => {
const fullPath = await resolve(specifier, import.meta.url).then(
Expand All @@ -221,7 +221,7 @@ const loadConfig = async (specifier, { resolve, readFile }) => {
* @param {string[]} args
* @param {object} io
* @param {typeof import('process').stdout} io.stdout
* @param {typeof import('fs/promises')} io.fsp
* @param {typeof import('fs/promises.js')} io.fsp
* @param {{
* resolve: Resolver;
* url: string;
Expand Down Expand Up @@ -266,7 +266,7 @@ const main = async (args, { stdout, fsp, meta }) => {

const run = async () => {
const [fsp, metaResolve] = await Promise.all([
import('fs/promises'),
import('fs/promises.js'),
import('import-meta-resolve'),
]);

Expand Down
2 changes: 1 addition & 1 deletion packages/cache/src/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { makeScalarStoreCoordinator } from './store.js';
*/

/**
* @param {ERef<import('./types').Coordinator>} [coordinator]
* @param {ERef<import('./types.js').Coordinator>} [coordinator]
*/
export const makeCache = (coordinator = makeScalarStoreCoordinator()) => {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const makeState = (value, priorState = GROUND_STATE) =>
/**
* Wrap a state store to have a default value using the GROUND_STATE
*
* @param {MapStore<string, import('./state').State>} stateStore
* @param {MapStore<string, import('./state.js').State>} stateStore
*/
export const withGroundState = stateStore => ({
...stateStore,
Expand Down
20 changes: 10 additions & 10 deletions packages/cache/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const makeKeyToString = (sanitize = obj => obj) => {
* @param {(obj: unknown) => unknown} sanitize Process keys and values with
* this function before storing them
* @param {{
* get(key: string): import('./state').State;
* set(key: string, value: import('./state').State): void;
* init(key: string, value: import('./state').State): void;
* get(key: string): import('./state.js').State;
* set(key: string, value: import('./state.js').State): void;
* init(key: string, value: import('./state.js').State): void;
* }} stateStore
* @returns {Promise<unknown>} the value of the updated state
*/
Expand All @@ -56,8 +56,8 @@ const applyCacheTransaction = async (
/**
* Retrieve a potential updated state from the transaction.
*
* @param {import('./state').State} basisState
* @returns {Promise<import('./state').State | null>} the updated state, or null if no longer applicable
* @param {import('./state.js').State} basisState
* @returns {Promise<import('./state.js').State | null>} the updated state, or null if no longer applicable
*/
const getUpdatedState = async basisState => {
const { value } = basisState;
Expand Down Expand Up @@ -106,7 +106,7 @@ const applyCacheTransaction = async (
};

/**
* @param {MapStore<string, import('./state').State>} stateStore
* @param {MapStore<string, import('./state.js').State>} stateStore
* @param {ERef<Marshaller>} marshaller
* @returns {Promise<string>}
*/
Expand All @@ -124,7 +124,7 @@ const stringifyStateStore = async (stateStore, marshaller) => {
* Make a cache coordinator backed by a MapStore. This coordinator doesn't
* currently enforce any cache eviction, but that would be a useful feature.
*
* @param {MapStore<string, import('./state').State>} [stateStore]
* @param {MapStore<string, import('./state.js').State>} [stateStore]
* @param {(obj: unknown) => unknown} [sanitize] Process keys and values with
* this function before storing them. Defaults to deeplyFulfilled.
*/
Expand All @@ -136,7 +136,7 @@ export const makeScalarStoreCoordinator = (

const defaultStateStore = withGroundState(stateStore);

/** @type {import('./types').Coordinator} */
/** @type {import('./types.js').Coordinator} */
const coord = Far('store cache coordinator', {
getRecentValue: async key => {
const keyStr = await serializePassable(key);
Expand Down Expand Up @@ -169,7 +169,7 @@ export const makeScalarStoreCoordinator = (
/**
* Don't write any marshalled value that's older than what's already pushed
*
* @param {MapStore<string, import('./state').State>} stateStore
* @param {MapStore<string, import('./state.js').State>} stateStore
* @param {ERef<Marshaller>} marshaller
* @param {ERef<StorageNode>} storageNode
* @returns {<T>(storedValue: T) => Promise<T>}
Expand Down Expand Up @@ -216,7 +216,7 @@ export const makeChainStorageCoordinator = (storageNode, marshaller) => {
storageNode,
);

/** @type {import('./types').Coordinator} */
/** @type {import('./types.js').Coordinator} */
const coord = Far('store cache coordinator', {
getRecentValue: async key => {
const keyStr = await serializePassable(key);
Expand Down
Loading

0 comments on commit 7b43ada

Please sign in to comment.