chore(types): make the repo type-check clean under tsgo (TS7 native-preview)#12703
Conversation
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
cd042f9 to
54cd956
Compare
| * @import {SlogProps} from './controller/controller.js'; | ||
| * @import {StartDuration} from './kernel/slogger.js'; | ||
| * @import {CapData} from '@endo/marshal'; | ||
| * @import {Message} from '@agoric/swingset-liveslots'; |
There was a problem hiding this comment.
The regression from @import is unfortunate.
There was a problem hiding this comment.
I see it's only for self-referential cases.
| // TODO re-export these | ||
| /** | ||
| * @template T @typedef {DefineKindOptions<T>} DefineKindOptions | ||
| * @template T @typedef {import('@agoric/swingset-liveslots').DefineKindOptions<T>} DefineKindOptions |
There was a problem hiding this comment.
oic... the @import regression is only in these otherwise-circular cases
| @@ -0,0 +1,659 @@ | |||
| /** | |||
There was a problem hiding this comment.
I presume this 450 lines of JSDoc was correctly converted to .ts. I spot-checked that a comment was not dropped.
d13fef3 to
f00cec8
Compare
f00cec8 to
98985ef
Compare
There was a problem hiding this comment.
Pull request overview
This PR makes the repository type-check clean under tsgo (TypeScript 7 native preview) while preserving compatibility with legacy tsc, and wires tsgo quickcheck into CI to prevent regressions. The bulk of the change-set is JSDoc/type-level adjustments and targeted casts to accommodate tsgo’s stricter/in-different inference and JSDoc binding behavior.
Changes:
- Add
@typescript/native-previewand atypecheck-tsgoscript, and run it in GitHub Actions alongsidetypecheck-quick. - Refactor/adjust many JSDoc typings (notably
@enum→@typedef,typeof import(...)patterns, and narrowed/widened parameter typings) to satisfy bothtscandtsgo. - Restructure some exported type surfaces (notably SwingSet external types) to be TS-backed while keeping runtime exports empty.
Reviewed changes
Copilot reviewed 200 out of 202 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Add native-preview dependency resolutions. |
| packages/zoe/tools/setup-zoe.js | JSDoc param widening for bundling helper. |
| packages/zoe/tools/fakeVatAdmin.js | Type-directed refactor + casts for vatParameters/root typing. |
| packages/zoe/test/unitTests/zoe-env.test.js | Cast global VatData for tsgo compatibility. |
| packages/zoe/test/unitTests/zcf/zcfSeat.test.js | Assert test jig + safer cast for zcf. |
| packages/zoe/test/unitTests/zcf/setupZcfTest.js | Template default tweak + cast terms for startInstance typing. |
| packages/zoe/test/unitTests/zcf/offer-proposalShape.test.js | Assert test jig + safer cast for zcf. |
| packages/zoe/test/unitTests/makeKind.test.js | Cast global VatData for tsgo compatibility. |
| packages/zoe/test/unitTests/contractSupport/offerTo.test.js | Cast offerResult for membrane/generic typing. |
| packages/zoe/test/unitTests/contracts/valueVow.test.js | Cast contractFile for bundle/install typing. |
| packages/zoe/test/unitTests/contracts/brokenAutoRefund.js | Cast start fn to loosen typing for intentionally-broken contract. |
| packages/zoe/src/zoeService/zoeStorageManager.js | Type-directed refactor of manager factory function. |
| packages/zoe/src/zoeService/zoeSeat.js | Remove redundant typedef comment for WeakMap. |
| packages/zoe/src/zoeService/startInstance.js | Type-directed refactor + cast privateArgs for startZcf. |
| packages/zoe/src/zoeService/originalZoeSeat.js | Remove redundant typedef comment for WeakMap. |
| packages/zoe/src/issuerRecord.js | Convert assertion arrow to function decl for better narrowing. |
| packages/zoe/src/internal-types.js | JSDoc tweaks (baggage optional; callback→typedef). |
| packages/zoe/src/contractSupport/topics.js | Relax topic record generic + constrain template. |
| packages/zoe/src/contractSupport/durability.js | Replace ts-expect-error with explicit cast. |
| packages/zoe/src/contracts/valueVow.contract.js | Cast invitation handler to satisfy typing. |
| packages/zoe/src/contracts/scaledPriceAuthority.js | Cast privateArgs for optional override field access. |
| packages/zoe/src/contracts/priceAggregatorTypes.js | Template JSDoc adjustment. |
| packages/zoe/src/contracts/auction/index.js | Fix union typing for const options + annotate nullable timestamp. |
| packages/xsnap/test/xsnap-eof.test.js | Use ReturnType<typeof fn> in typedefs. |
| packages/xsnap/test/message-tools.js | typeof import(...) JSDoc fixes for node APIs. |
| packages/xsnap/test/leakiness.test.js | Annotate nullable vat handle with typeof import(...). |
| packages/xsnap/test/leakiness.mjs | ReturnType<typeof xsnap> JSDoc fixes. |
| packages/xsnap/src/replay.js | typeof import(...) JSDoc fixes for fs/spawn typings. |
| packages/xsnap/src/build.js | typeof import(...) JSDoc fixes for spawn typings. |
| packages/xsnap/src/avaXS.js | typeof import('path')... JSDoc fixes. |
| packages/wallet/api/src/lib-dehydrate.js | Constrain template with Key and import it. |
| packages/vow/src/watch-utils.js | Cast rest args to satisfy spread typing. |
| packages/vow/src/retryable.js | Type-directed refactor of retryable wrapper function. |
| packages/vats/tools/fake-bridge.js | Widen message param typing to Record<string, any>. |
| packages/vats/test/vat-bank-integration.test.js | Type-directed refactor of vat loader fn. |
| packages/vats/test/clientBundle.test.js | Type-directed refactor of vat loader fn. |
| packages/vats/src/proposals/zcf-proposal.js | Cast zoeRoot for method access through membrane typing. |
| packages/vats/src/proposals/zcf-only-proposal.js | Cast zoeRoot for method access through membrane typing. |
| packages/vats/src/proposals/namesByAddress-fix-proposal.js | Cast root for method access through membrane typing. |
| packages/vats/src/proposals/localchain-test.js | Use minimal non-generic interface to call queryMany. |
| packages/vats/src/proposals/localchain-hook-msg-send.js | Add missing imports + document nested options shape. |
| packages/vats/src/localchain.js | Cast requests for queryMany across membrane typing. |
| packages/vats/src/core/utils.js | Widen WeakMapStore value type for atomic provider. |
| packages/vats/src/core/startWalletFactory.js | typeof import(...).start typing fix. |
| packages/vats/src/core/basic-behaviors.js | Cast vat loaders; remove stale JSDoc type. |
| packages/vats/src/bridge.js | Fix generic template naming + return type annotation. |
| packages/vats/src/bridge-target.js | Reorder typedefs/interfaces to avoid tsgo JSDoc binding issue. |
| packages/vat-data/test/present.test.js | Cast globalThis VatData assignment for tsgo. |
| packages/vat-data/test/absent.test.js | Cast delete of VatData for tsgo. |
| packages/vat-data/src/index.js | Use import(...).Type form for exported typedef alias. |
| packages/vat-data/src/exo-utils.js | Import Methods and constrain behavior template. |
| packages/telemetry/src/index.js | Remove self-import JSDoc that confuses tooling. |
| packages/SwingSet/test/virtualObjects/vdata-promises/vat-vdata-promises.js | Use globalThis VatData with cast. |
| packages/SwingSet/test/virtualObjects/double-retire-import/vat-dri.js | Use globalThis VatData with cast. |
| packages/SwingSet/test/virtualObjects/delete-stored-vo/vat-delete-stored-vo.js | Use globalThis VatData with cast. |
| packages/SwingSet/test/virtualObjects/collection-slots/vat-collection-slots.js | Use globalThis VatData with cast. |
| packages/SwingSet/test/vat-env.test.js | Cast global for harden/VatData destructuring. |
| packages/SwingSet/test/upgrade/vat-ulrik-1.js | Relax tuple element typing to any[]. |
| packages/SwingSet/test/upgrade/bootstrap-scripted-upgrade.js | Relax tuple element typing to any[]. |
| packages/SwingSet/src/vats/timer/vat-timer.js | Fix mistaken @typedef to @type in locals. |
| packages/SwingSet/src/types-external.ts | New TS source of SwingSet external API types. |
| packages/SwingSet/src/types-external.js | Remove legacy JSDoc-only external types file. |
| packages/SwingSet/src/types-external-index.js | New empty runtime export target for type-only re-export. |
| packages/SwingSet/src/types-external-index.d.ts | Type-only re-export surface for external API types. |
| packages/SwingSet/src/kernel/vatTranslator.js | Annotate nullable slot vars. |
| packages/SwingSet/src/kernel/vat-loader/manager-subprocess-xsnap.js | Annotate nullable uncompressed size var. |
| packages/SwingSet/src/kernel/kernel.js | Type-directed refactor + import() type reference. |
| packages/SwingSet/src/index.js | Re-export external types via types-external-index. |
| packages/SwingSet/src/controller/startXSnap.js | typeof import(...) fixes for fs/tmpName typing. |
| packages/SwingSet/src/controller/initializeSwingset.js | Avoid property access typing issues by widening desc. |
| packages/SwingSet/src/controller/initializeKernel.js | Import Passable + cast bootstrap args for marshal serialize. |
| packages/SwingSet/misc-tools/replay-transcript.js | Tighten partial VatKeeper typing + widen loadSnapshotID union. |
| packages/swingset-xsnap-supervisor/lib/supervisor-subprocess-xsnap.js | Fix JSDoc template/typedef ordering. |
| packages/swingset-liveslots/tools/setup-vat-data.js | Cast global VatData to VatData type; remove expect-errors. |
| packages/swingset-liveslots/test/vo-test-harness.js | Cast null initializer for stricter inference. |
| packages/swingset-liveslots/test/gc-helpers.js | Cast null initializer for stricter inference. |
| packages/swingset-liveslots/src/virtualObjectManager.js | Use globalThis.WeakMap/WeakSet in JSDoc. |
| packages/swingset-liveslots/src/liveslots.js | Annotate nullable set; cast collected imports to Set. |
| packages/swingset-liveslots/src/collectionManager.js | Specify CapData for schemataCapData. |
| packages/swing-store/test/state.test.js | Annotate nullable dbDir. |
| packages/swing-store/test/import.test.js | Inline import(...).ArtifactMode type reference. |
| packages/swing-store/test/bundles.test.js | Inline import(...).Bundle type reference. |
| packages/swing-store/src/assertComplete.js | Move JSDoc imports to top-level for tsgo. |
| packages/swing-store/src/archiver.js | typeof import(...) fixes for fs/path/tmp typings. |
| packages/store/src/stores/scalarWeakSetStore.js | Introduce backing-collection view typedef for typing reuse. |
| packages/store/src/stores/scalarWeakMapStore.js | Introduce backing-collection view typedef for typing reuse. |
| packages/store/src/legacy/legacyWeakMap.js | Document backing WeakMap view and bivariant key typing. |
| packages/solo/src/vat-http.js | Widen decentralObjects param typing. |
| packages/smart-wallet/test/wallet-fun.contract.js | Widen args typing + format invitation handler call. |
| packages/smart-wallet/test/supports.js | Type-directed refactor of vat loader fn. |
| packages/smart-wallet/src/types.ts | Relax PublicTopic generic to any. |
| packages/portfolio-deploy/src/chain-info.build.js | typeof globalThis.fetch + execFileSync import typing fixes. |
| packages/portfolio-contract/test/portfolio.contract.test.ts | Cast delete target to Record for TS strictness. |
| packages/portfolio-api/src/resolver.js | @enum→@typedef for keyMirror types. |
| packages/portfolio-api/src/instruments.js | @enum→@typedef for keyMirror types. |
| packages/portfolio-api/src/constants.js | @enum→@typedef for keyMirror types. |
| packages/pola-io/src/net.js | Use typeof globalThis.fetch in io typing. |
| packages/pola-io/src/file.js | Remove misleading JSDoc return annotation. |
| packages/pegasus/src/contract.js | Wrap start with cast to satisfy ContractStartFn typing. |
| packages/orchestration/test/utils/address.test.ts | Replace expect-error with explicit cast for invalid test case. |
| packages/orchestration/test/types.test-d.ts | Relax ResolvedPublicTopic generic to any. |
| packages/orchestration/src/utils/exo-helpers.js | Relax template constraint to non-readonly record. |
| packages/orchestration/src/utils/address.js | Convert assertion arrow to function decl for better narrowing. |
| packages/orchestration/src/proposals/start-swap-anything.js | Replace JSDoc import with typeof import(...).start typedef. |
| packages/orchestration/src/proposals/start-send-anywhere.js | Replace JSDoc import with typeof import(...).start typedef. |
| packages/orchestration/src/proposals/start-axelar-gmp.js | Replace JSDoc import with typeof import(...).start typedef. |
| packages/orchestration/src/orchestration-api.ts | Relax public topics typing to any. |
| packages/orchestration/src/exos/portfolio-holder-kit.js | Relax ResolvedPublicTopic generic to any in state/api. |
| packages/orchestration/src/exos/local-orchestration-account.js | Cast queryMany request array for membrane typing. |
| packages/orchestration/src/exos/local-chain-facade.js | Cast queryMany requests for membrane typing. |
| packages/orchestration/src/exos/chain-hub.js | @enum→@typedef; fix template literal typedef to use const. |
| packages/orchestration/src/examples/basic-flows.flows.js | Relax ResolvedPublicTopic array typing to any. |
| packages/orchestration/src/examples/axelar-gmp-account-kit.js | Remove redundant typedef line. |
| packages/orchestration/src/examples/auto-stake-it.flows.js | Relax ResolvedPublicTopic array typing to any. |
| packages/orchestration/src/chain-info.js | @enum→@typedef for KnownNamespace. |
| packages/notifier/test/publish-kit.test.js | Replace JSDoc import alias with typedef; widen config cast. |
| packages/network/src/network.js | @enum→@typedef for RevokeState. |
| packages/internal/test/utils.test.js | Cast mapped tuple element to preserve generic typing. |
| packages/internal/test/marshal.test.js | Add WeakMap typing annotation. |
| packages/internal/src/tmpDir.js | Use typeof import('tmp') for tmp typing. |
| packages/internal/src/ses-utils.js | Fix return JSDoc to Promise; simplify/cast harden return. |
| packages/internal/src/node/shutdown.js | Annotate cached shutdown as nullable. |
| packages/internal/src/metrics.js | @enum→@typedef for metric aspect/type typedefs. |
| packages/internal/src/marshal/wrap-marshaller.js | Add casts for slot arrays/Passable typing across membrane. |
| packages/internal/src/marshal/board-client-utils.js | Clarify return typing comment; avoid conditional return JSDoc. |
| packages/internal/src/lib-nodejs/ava-unhandled-rejection.js | Remove stale JSDoc local type. |
| packages/internal/src/keyMirror.js | Document @typedef pattern for tsgo compatibility. |
| packages/internal/src/js-utils.js | Fix keyof typeof usage for LogLevel typedef. |
| packages/internal/src/config.js | @enum→@typedef; adjust satisfies type for bridge id map. |
| packages/internal/src/build-cache.js | Use typeof import('node:fs/promises') in JSDoc. |
| packages/internal/src/batched-deliver.js | Use typeof globalThis.setTimeout/clearTimeout in JSDoc. |
| packages/internal/src/action-types.js | @enum→@typedef for keyMirror-defined types. |
| packages/inter-protocol/test/swingsetTests/psmUpgrade/bootstrap-psm-upgrade.js | Fix typeof import(...) shape for buildRootObject typing. |
| packages/inter-protocol/test/swingsetTests/fluxAggregator/bootstrap-fluxAggregator-service-upgrade.js | Refine ReturnType/Awaited typing + cast limited facet. |
| packages/inter-protocol/test/smartWallet/oracle-integration.test.js | Replace JSDoc import alias with typedef. |
| packages/inter-protocol/test/psm/psm.test.js | Cast getBody return to object for typing. |
| packages/inter-protocol/test/metrics.js | Cast diff inputs to object for typing. |
| packages/inter-protocol/src/vaultFactory/vaultManager.js | Cast invitation to satisfy offerTo typing mismatch. |
| packages/inter-protocol/src/vaultFactory/vaultDirector.js | Cast facet return through unknown to break inference cycle. |
| packages/inter-protocol/src/vaultFactory/vault.js | @enum→@typedef; cast to break Vault↔VaultKit inference cycle. |
| packages/inter-protocol/src/proposals/replace-scaledPriceAuthorities.js | Refine config/options typing and cast partial InterchainAssetOptions. |
| packages/inter-protocol/src/proposals/econ-behaviors.js | Replace JSDoc import alias with typedef for start fn. |
| packages/inter-protocol/src/proposals/addAssetToVault.js | Replace JSDoc import with typedef; refine options typing. |
| packages/inter-protocol/src/auction/util.js | @enum→@typedef for AuctionState. |
| packages/governance/test/unitTests/binaryballotCount.test.js | Fix type annotation to typeof for const. |
| packages/governance/src/types.js | Remove stale template annotation line. |
| packages/governance/src/contractGovernorKit.js | Relax LimitedCF generic to any. |
| packages/governance/src/constants.js | @enum→@typedef for ParamType. |
| packages/fast-usdc/src/constants.js | @enum→@typedef for TxStatus/PendingTxStatus. |
| packages/fast-usdc/src/clientSupport.js | Cast proposal object via unknown; preserve runtime. |
| packages/fast-usdc/src/cli/util/file.js | Replace JSDoc imports with typedefs for fs functions. |
| packages/fast-usdc/src/cli/config-commands.js | Fix parameter typing to typeof ConfigHelpers. |
| packages/eslint-plugin/src/rules/group-jsdoc-imports.js | Remove example JSDoc import line. |
| packages/ERTP/test/unitTests/issuerObj.test.js | Use explicit callback lambdas for t.throwsAsync. |
| packages/ERTP/src/ratio.js | Convert assertion arrow to function decl for narrowing. |
| packages/ERTP/src/amountMath.js | @enum→@typedef; rework makeEmpty typing/cast. |
| packages/deploy-script-support/src/parseCoreEvalArgs.js | Move JSDoc import to top-level. |
| packages/deploy-script-support/src/externalTypes.js | Replace JSDoc import alias with typedef for writeFile. |
| packages/deploy-script-support/src/coreProposalBehavior.js | Use typeof import('@endo/far').E in JSDoc. |
| packages/deploy-script-support/src/cachedBundleSpec.js | Fix fs param typing to typeof promises. |
| packages/cosmic-swingset/tools/test-kit.js | typeof import(...) JSDoc for fsp mkdir typing. |
| packages/cosmic-swingset/tools/inquisitor.mjs | Fix ReturnType JSDoc to typeof makeX. |
| packages/cosmic-swingset/test/scenario2.js | typeof import(...) JSDoc fixes; clarify opts shape. |
| packages/cosmic-swingset/src/sim-params.js | @enum→@typedef for VatCleanupPhase. |
| packages/cosmic-swingset/src/launch-chain.js | @enum→@typedef; remove stale template in LaunchOptions typedef. |
| packages/cosmic-swingset/src/import-kernel-db.js | Convert validators to function decls; typeof import(...) JSDoc. |
| packages/cosmic-swingset/src/helpers/json-stable-stringify.js | Add JSDoc + cast for tsgo typing. |
| packages/cosmic-swingset/src/export-kernel-db.js | Convert validators to function decls; typeof import(...) JSDoc. |
| packages/cosmic-swingset/src/chain-main.js | Add nullable promise var; typeof import(...) JSDoc fixes. |
| packages/cosmic-proto/test/address-hooks.test.js | Use typeof import(...) for module typing in tests. |
| packages/client-utils/src/sync-tools.js | Widen offerStatus/update param typing to Record<string, any>. |
| packages/client-utils/src/network-config.js | Use typeof globalThis.fetch in io typing. |
| packages/client-utils/src/marshalTables.js | Replace expect-error with explicit cast for Map.get. |
| packages/client-utils/src/cli.js | Use typeof globalThis.fetch in io typing. |
| packages/casting/src/netconfig.js | Convert assertion arrow to function decl + harden. |
| packages/casting/src/follower-cosmjs.js | Use import(...).QueryClient typing; annotate local height var. |
| packages/cache/src/state.js | Remove self-import JSDoc that confuses tooling. |
| packages/builders/scripts/testing/upgrade-send-anywhere.js | Replace JSDoc import with typedef; fix param doc shape. |
| packages/builders/scripts/testing/start-valueVow.js | Replace JSDoc import with typedef for start fn. |
| packages/builders/scripts/testing/restart-valueVow.js | Replace JSDoc import with typedef for start fn. |
| packages/builders/scripts/testing/restart-stakeAtom.js | Replace JSDoc import with typedef for start fn. |
| packages/builders/scripts/testing/restart-send-anywhere.js | Replace JSDoc import with typedef for start fn. |
| packages/builders/scripts/testing/restart-basic-flows.js | Replace JSDoc import with typedef for start fn. |
| packages/builders/scripts/testing/restart-axelar-gmp.js | Replace JSDoc import with typedef for start fn. |
| packages/builders/scripts/orchestration/get-chain-config.js | Fix execFileSync typing in JSDoc. |
| packages/boot/tools/authorityViz.js | Replace JSDoc imports with typeof import(...) annotations. |
| packages/boot/test/configs.test.js | Fix spawn typing in helper JSDoc. |
| packages/boot/test/bootstrapTests/vats-restart.test.ts | Cast ibc for EV membrane call typing. |
| packages/benchmark/src/benchmarkerator.js | Use Record<string, any> for benchmarkContext typing. |
| packages/async-flow/test/replay-membrane-eventual.test.js | Fix keyMirror-derived union type expression. |
| packages/async-flow/test/bijection.test.js | Remove unused JSDoc import line. |
| packages/async-flow/src/replay-membrane.js | Replace expect-error with explicit resolve/reject casts. |
| packages/agoric-cli/test/upgrade-contract/init-proposal.js | Widen promiseSpace typing to Record<string, any>. |
| packages/agoric-cli/src/scripts.js | Fix template JSDoc generic naming and bounds. |
| packages/agoric-cli/src/publish.js | Convert asserts to function decls for narrowing. |
| packages/agoric-cli/src/proposals.js | Fix fs param typing to typeof FsPromises throughout. |
| packages/agoric-cli/src/lib/packageManager.js | Fix execFileSync typing via typeof import(...). |
| packages/agoric-cli/src/deploy.js | Annotate progress timer nullable; clearInterval null-safe. |
| packages/agoric-cli/src/commands/test-upgrade.js | Replace commander/exec typings with typeof import(...). |
| packages/agoric-cli/src/commands/oracle.js | Replace commander/exec typings with typeof import(...). |
| package.json | Add native-preview dep; add typecheck-tsgo; tweak typecheck-all grep. |
| .github/workflows/test-all-packages.yml | Add typecheck-tsgo step; run codegen idempotence job unconditionally. |
Comments suppressed due to low confidence (1)
.github/workflows/test-all-packages.yml:292
- The
test-codegenjob is no longer limited to pull requests (the previousif: github.event_name == 'pull_request'gate was removed). That will run codegen idempotence checks on pushes/merges too, which can significantly increase CI time and load (it also installs Go). If this wasn't intentional, re-add the PR-only guard; if it was intentional, consider documenting the rationale (and/or scoping when it should run).
# Verify that running `yarn codegen` in any package that defines it
# does not produce changes.
test-codegen:
needs: build
runs-on: ubuntu-latest
steps:
| /** | ||
| * @param {unknown} obj | ||
| * @param {any} [opts] | ||
| * @returns {string} | ||
| */ |
There was a problem hiding this comment.
Interesting. I suspect callers ensure that it returns string by not passing in undefined. So assert(obj) is another option, though it has runtime effect, unlike the rest of the changes in this PR.
There was a problem hiding this comment.
true but if that runtime change is just earlier detection of a runtime failure (undefined over the bridge) so I added the runtime check
| // Returns a string for any JSON-serializable input; `undefined` only for | ||
| // `undefined`/function inputs, matching the upstream `=> string` typing. | ||
| return /** @type {string} */ (stringify({ '': obj }, '', obj, 0)); |
TypeScript 7.0 reworked JavaScript/JSDoc analysis to be consistent with
how it analyzes .ts files (see the "JavaScript Differences" section of the
7.0 beta announcement). Under the old tsc, JSDoc resolved `typeof execFileSync`
leniently to the `@import`ed name. TS7 now applies the same scope-resolution
rule it has always used for .ts: the destructured parameter `{ execFileSync }`
shadows the import within its own type annotation, making `typeof execFileSync`
self-referential and emitting TS2502 ("referenced directly or indirectly in
its own type annotation").
This is intended, by-design behavior — not a tsgo bug. The identical pattern
in a .ts file produces the same TS2502 in both tsc and tsgo; only old tsc's
JS-specific leniency hid it.
Rewriting the annotation as `typeof import('child_process').execFileSync`
removes the bare identifier, so there is nothing to shadow and the type
resolves correctly. This also drops the now-unused `@import`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The native `tsgo` (TypeScript 7 preview) does not honor the `@enum` JSDoc
tag as a type declaration, so every type-position use of the enum name
became TS2749 ("refers to a value, but is being used as a type here").
Replace `@enum {T}` on `export const X` with `@typedef {T} X`. Because
types and values occupy separate declaration namespaces, the typedef
merges with the const instead of colliding, and a top-level @typedef in
an ES module stays importable as a type. This form resolves under both
the legacy `tsc` and `tsgo`. Update the keyMirror docs to recommend it.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`tsgo` is stricter than the legacy `tsc` about using a value where a type
is expected (TS2749). Provide the missing `typeof`:
- where a value (const, parameter, imported function, or global) was used
directly in a type position, e.g. `ReturnType<xsnap>` ->
`ReturnType<typeof xsnap>`, `keyof logLevels` -> `keyof typeof logLevels`;
- convert `@import {value as Alias}` (a value import used as a type) into
`@typedef {typeof import('mod').value} Alias`, which fixes every use site
at once;
- reference globals explicitly (`typeof globalThis.clearTimeout`) to avoid
resolving to a same-named destructured parameter;
- make `boardValToSlot` generic instead of referencing its `val` parameter
as a type;
- drop a self-referential `@type {startGovernedUpgradable}` annotation that
named no real type.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Once the enum/value names above resolve to real types, two latent issues
that the previously-`any` types had masked surface as errors:
- bridge.js: `@template {BridgeId} BridgeId` named the type parameter
identically to its imported constraint, which is now a real type and
produces a circular constraint (TS2313). Rename the parameter to `B`.
- leakiness.test.js: `let lastVat = null` could absorb the formerly-`any`
vat; annotate it with the now-concrete xsnap instance type.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Newer lib typings constrain `WeakMap`/`WeakSet` keys to `K & object` and add `Map.prototype.getOrInsertComputed`, whose contravariant callback made the shared `makeWeakMapStoreMethods`/`makeWeakSetStoreMethods` helpers reject both their `WeakMap<K & object, V>` keys (vs the public `K extends Key`, which includes primitives) and the `Map<K, V>` the non-weak scalar stores reuse them with (TS2345). These stores only ever hold object keys, but the helpers serve both weak and strong backings, so no single concrete key type fits. Type the backing parameter as a minimal structural view whose methods take the key bivariantly (`any`), which both `Map<K, V>` and `WeakMap<K & object, V>` satisfy while the methods keep operating on `K`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- ses-utils: declare the generic `extract`/`allValues` shapes inline in the function type (tsgo doesn't bind `@template` declared on a const to its `@type`); cast `allValues` result instead of a mislocated @ts-expect-error. - build-cache, tmpDir: `typeof import('mod')` for module-namespace-as-type. - shutdown: annotate the null-initialized cache with its real value type. - ava-unhandled-rejection: drop a stray `@type {string}` on a Macro return. - wrap-marshaller: reconcile arrays built via `Array.from({length})` (which carry undefined/null) with their declared element types. - tests: type a mock WeakMap, fix an fc.tuple().map() tuple destructure, and replace an unbindable `@template F` macro type with a typedef. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- types-external: use inline-import typedefs instead of `@import` + a
same-name `@typedef` (tsgo rejects the re-export idiom as a conflict);
include VatConfigOptions in SwingSetConfigProperties so `parameters` etc.
are accepted.
- startXSnap: `typeof import('mod')` for module-namespace-as-type.
- kernel: cast the type-guard arrow (tsgo won't widen a `boolean` return to
a `x is T` predicate); inline a stray function-scoped `@import`; annotate
the null-initialized `kernelPanic`.
- vatTranslator / manager-subprocess-xsnap: annotate null-initialized
`let`s with their real types.
- vat-timer: `@type` instead of `@typedef` for local annotations.
- initializeSwingset: cast `desc` for defensive debug-log property reads.
- replay-transcript: widen loadSnapshotID to include null; add an unknown
intermediate for the Partial<VatKeeper> cast.
- tests: `...any[]` rest elements; cast the `VatData` vat-global.
- remove a now-unused @ts-expect-error in initializeKernel.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… typedef (tsgo) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…etch (tsgo) Let readdir infer to break the FileRd <- ReturnType<typeof makeFileRd> cycle (TS2456); reference the fetch global explicitly to avoid a parameter naming itself (TS2502). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…pread (tsgo) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Annotate null-initialized variables (importedPromises, test held/heldStore); type schemataCapData as CapData so .slots resolves; reference the WeakMap/ WeakSet globals via globalThis to avoid a self-referential param type; cast the exclusively-owned imports Set to non-null. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
typeof import('mod') for module-namespace-as-type in archiver; hoist/inline
@import declarations out of function bodies (tsgo requires top-level, which
also fixes their module resolution); annotate a null-initialized dbDir.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The io-power params are destructured in the body, so JSDoc `typeof dirname`
etc. resolved to the param itself (TS2502). Qualify with inline module
imports (typeof import('path').dirname, ...) and use typeof import('mod') for
module-namespace-as-type.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
tsgo only treats a JSDoc assertion (asserts x is T) as usable when declared on a function declaration, not a const arrow. Callers (e.g. priceAggregator) otherwise hit TS2775. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- setupZCFTest: default the terms generic to Record<string, unknown> so the produced ZCF matches the default ZCF (fixes ~40 test errors at once). - relax over-strict generic constraints (OracleAdmin result); fix usages of PublicTopic<unknown>; type a CapData; let WeakMap stores infer. - syntax: @typedef->@type, @callback->@typedef, optional-before-required param. - make assertFullIssuerRecord a function declaration (assertion usability). - annotate null-initialized vars; cast cross-layer generic function mismatches (startInstance, zoeStorageManager, fakeVatAdmin, valueVow) to their declared interface types; remove now-unused @ts-expect-error directives. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Constrain makeMapping's @template T to {Key} T (Mapping<T> requires T extends Key) and import Key from @endo/patterns. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- constrain defineVirtualExoClass @template T to {Methods} (Guarded<T> requires it) - inline DefineKindOptions re-export to avoid import/typedef name conflict (TS2440) - drop now-unused @ts-expect-error directives in present/absent tests Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Convert orchestration's assertBech32Address from a const arrow to a function declaration so callers get assertion narrowing (TS2775). This narrows destinationAddress to Bech32Address, also resolving the ReimbursementTerms assignment (TS2322) in reimburse-manual-intervention.build.js. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- qualify typeof fetch (globalThis) and typeof execFileSync (import) self-refs; drop redundant @import execFileSync (TS2502) - widen zoe setup-zoe bundleAndInstall/bundleModule pathOrExports to string | object (the body already handles string paths), fixing the string-path call in contract-control.test (TS2345) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… (tsgo TS2339) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- PublicTopic<unknown> -> <any> (constraint requires object; fix usage per plan) - wrap test vatLoader in VatLoader cast; type offer args as Record<string,any> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rop unused @ts-expect-error (tsgo TS2322/TS2578) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- cast makeEmpty impl to its overload type instead of const-annotation (tsgo won't widen the impl); drop now-unused @ts-expect-error (TS2322/TS2578) - use zero-arg throwers in issuerObj throwsAsync calls (TS2769) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- type registerScaledPriceAuthority/replaceScaledPriceAuthority options .interchainAssetOptions (TS2339/TS2322); cast the issuerName-only replacement options (keyword unused on that path) - break Vault<->VaultKit type-inference cycle by casting makeTransferInvitationHook's return (Vault referenced VaultKit, which references Vault via holder state) (TS2456/TS2339) - cast vaultDirector getPublicFacet through unknown (TS2352) - cast reserve invitation (string offer result) for offerTo (TS2345) - qualify module-as-type with typeof import(...) in bootstrap-psm-upgrade (TS1340) - cast getStorageChildBody return to object; drop unused @ts-expect-error directives (TS2322/TS2578) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- inline QueryClient type (conflicted with local const, TS2440) - annotate thisHeight as number so cursorBlockHeight narrows (TS2345/TS18048) - convert assertNetworkConfig to a function declaration for caller narrowing (TS2775) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- typeof childProcess.execFileSync (value used as type, TS2724) - type upgrade-send-anywhere second param instead of ...any rest (TS2339) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- cast Map.get() results after has() (TS issue 13086); drop the mislocated @ts-expect-error directives in marshalTables (TS2322/TS2578) - typeof globalThis.fetch for fetch param self-references (TS2502) - type sync-tools checkOfferState/checkLiveOffers params as Record<string,any> (TS2339) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…typing (tsgo) The per-package check (skipLibCheck drops the VatData ambient global) and the repo-wide quickcheck (which picks it up) disagreed on @ts-expect-error usage. Use casts that hold in both contexts: - vat-data tests: cast globalThis to any for delete/assign of VatData - setup-vat-data: cast the VatData object literal to VatData so the method arrows get contextual typing, removing the spread-arg @ts-expect-errors Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- qualify typeof self-references (createCommand/execFileSync/setTimeout) and drop redundant @import lines (TS2502) - typeof for FsPromises namespace and fs/promises module used as types (TS2709/TS1340) - rename shadowing @template ModuleFormat -> MF (circular constraint, TS2313/TS2344/TS2322/TS2769) - annotate progressTimer as ReturnType<typeof setInterval> | null; clearInterval(?? undefined) (TS2322/TS2769) - type init-proposal test promiseSpace as Record<string,any> (TS2339) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…test (tsgo TS1340) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…(tsgo TS2315/TS2304/TS6196) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… (tsgo TS2339) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…(tsgo TS2307) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The JSDoc @typedef form tripped a class of lint rules (no-typedef-import, group-jsdoc-imports, reject-any-type, escape-inline-tags, ts-no-empty-object-type) and forced inline import() inside typedefs. Rewrite ~80 @typedefs as `export type`/`export interface` with real `import type` declarations. Because SwingSet ships untranspiled .js, the package root re-exports these types through a runtime-free .js/.d.ts twin (types-external-index), mirroring swingset-liveslots' types-index pattern, so index.js's `export *` stays a runtime no-op while types still flow. VatAdminFacet stays a type alias (not interface) so Guarded<VatAdminFacet> satisfies @endo/exo's Methods index-signature constraint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
tsgo (TypeScript 7 native) rejects JSDoc that names a parameter value in
type position, which legacy tsc silently tolerated. In ses-utils.js the
async helpers declared `@returns {ReturnType<trier>}` / `ReturnType<fn>`,
referencing the value params `trier`/`fn`. Both functions are async with
`@template T` and resolve to `Promise<T>`, so state that directly — which
also satisfies TS1064 (async return must be the global Promise type).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Why a workaround was necessary
------------------------------
`boardValToSlot` declared `@returns {val extends BoardRemote<infer BoardId>
? BoardId : never}`, naming the *value* parameter `val` in type position.
tsgo (TypeScript 7 native) rejects this with TS2749 ("'val' refers to a
value, but is being used as a type"); legacy tsc silently tolerated it.
Per the TS 7.0 "JavaScript Differences", this is intentional: values can no
longer be used where types are expected.
Why not the obvious mechanical fixes
------------------------------------
- `typeof val extends ...` (tsgo's own suggestion) changes the *meaning*:
`typeof val` is the union `BoardRemote<any> | object`, and a union in a
non-naked conditional does not distribute, so it collapses to `never` for
every caller. Silent semantic change, worse than the original.
- Making the function generic (`@template V`, `val: V`) satisfies both
compilers at the signature but breaks the body under legacy tsc: the
`'getBoardId' in val` narrowing no longer applies to a bare type param
("V not assignable to object"; getBoardId is `unknown`).
Why the slight regression in expressivity is acceptable
-------------------------------------------------------
The conditional return type was never actually observed: at its sole call
site (`boardSlottingMarshaller`) the function is cast to
`ConvertValToSlot<BoardId>`, which fully replaces this signature. So the
"extract BoardId from the BoardRemote" return type bought callers nothing.
Dropping `@returns` and letting inference stand loses that bit of
self-documentation but has zero effect on consumers, and is the only form
that type-checks cleanly under BOTH tsc and tsgo without a semantic change.
A comment records the call-site cast so the omission is intentional, not an
oversight.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
98985ef to
614edbe
Compare
tsgo requires an assertion function to be a `function` declaration, not a `const` arrow, for its `asserts` narrowing to apply at call sites (TS2775). Convert assertHttpConnectionSpec and assertCosmosConnectionSpec. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ect-error tsgo and legacy tsc attribute the overload error of a multi-line call to different physical lines, so a single `@ts-expect-error` placement can't satisfy both (unused under one, needed under the other). Replace it with an explicit `as unknown as Bech32Address` cast on the deliberately-invalid input — no error to misattribute, and it survives dprint re-wrapping. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tsgo TS2339) `/** @type {object} */` rejected the title/rounds/config property assignments tsgo now enforces. The context is built up dynamically, so Record<string, any> is the honest type. Clean under tsc and tsgo. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add `typecheck-tsgo` (tsgo -p tsconfig.quickcheck.json) and run it in the lint-rest CI job alongside the legacy `typecheck-quick`. This keeps the repo green under tsgo for the TS7 migration and prevents regressions. CI runs on a fresh checkout, so the config's `incremental` cache cannot mask errors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…packages) Since 8172e42 (ci: eslint repo, 2026-03-16) the root typecheck-all script has guarded each workspace with rg -q '"lint:types"' package.json || exit 0; tsc --noEmit ... ripgrep is not installed on the ubuntu-24.04 GitHub runner image (it does not appear in the image's included-software manifest), so in the lint-primary job every workspace printed 'sh: 1: rg: not found' (exit 127), which the '|| exit 0' skip-guard swallowed. Result: all ~60 workspaces were skipped and the step reported success while type-checking nothing. Evidence: master lint-primary logs from runs 24714364349 (2026-04-21), 26775460738 (2026-06-01), 26305924107 (2026-05-22), and 27224235741 (2026-06-09) each contain the same 60 'rg: not found' lines and the job passed. Master runs that appeared clean had skipped lint-primary entirely. The script only worked on dev machines where ripgrep happens to be installed. grep is POSIX and present on every runner; the fixed-string pattern behaves identically. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
614edbe to
63b49f6
Compare
What
Drives
tsgo -p tsconfig.quickcheck.json(the@typescript/native-preview/ TS7 binary) from 205 → 0 errors across the repo, one package at a time in reverse-dependency BFS order from@agoric/store. SeePLAN.mdfor the full per-package log, the recurring tsgo-vs-tsc patterns, and remaining follow-up work.All fixes were chosen to work under both legacy
tscandtsgo. The vast majority are type-level only (JSDoc@import/typeof/@templatecorrections and narrow casts); a few convert const-arrow assertion functions to function declarations so callers get narrowing.Highlights / non-mechanical fixes
VatDatatest/vat global (vat-data,swingset-liveslots) — the per-package check and the repo-wide quickcheck disagreed on@ts-expect-errorusage becauseskipLibCheckdrops the ambient global in one context but not the other. Fixed with casts that hold in both.Vault↔VaultKittype-inference cycle ininter-protocolvaultFactory (tsgo refuses to resolve it lazily, unlike tsc).E()-membrane generic collapse:queryMany<RT extends TypedJson[]>can't bind across eventual-send, so call-siteanycasts invats/orchestrationlocalchain plumbing.ERTP/ratio.js,orchestration/utils/address.js(assertBech32Address → function decl),zoe/tools/setup-zoe.js(widened param).Recurring patterns (documented in PLAN.md)
@enum→@typedef, module/namespace-as-type →typeof import('mod'), self-referentialtypeof x→typeof globalThis.x/typeof import('mod').x, assertion arrows → function declarations, over-strictobjectparams →Record<string, any>, and<unknown>→<any>where a constraint requiresobject.Scope / what's left
tsconfig.quickcheck.jsonis clean. Genuinely-excluded packages (benchmark,create-dapp,stat-logger,swingset-runner,xsnap-lockdown,a3p-integration,multichain-testing) were not touched.tscparity end-to-end, run the test suite, optionally tighten the deliberateanycasts later.Test plan
tsgo -p tsconfig.quickcheck.json→ 0 errors🤖 Generated with Claude Code