Skip to content

upgrade to TypeScript 6#3171

Open
turadg wants to merge 8 commits intomasterfrom
typescript-6
Open

upgrade to TypeScript 6#3171
turadg wants to merge 8 commits intomasterfrom
typescript-6

Conversation

@turadg
Copy link
Copy Markdown
Member

@turadg turadg commented Apr 8, 2026

incidental

Description

Upgrade to TypeScript 6. Fix resulting errors.

Fixes bundleSource's return type to be conditional on the format argument.

Speeds up repo-wide TS checks by enabling TS incremental compilation and adds "test" to the main tsconfig so it covers those paths.

Security Considerations

none

Scaling Considerations

none

Documentation Considerations

none

Testing Considerations

CI

Compatibility Considerations

no runtime changes

  • Renaming EndoInspector<Record>EndoInspector<RecordT> is a non-breaking change in TS6 because generic type parameter names are erased — callers reference the type positionally, not by name. But TS6 started warning when a type parameter shadows a built-in like Record<K,V>, hence the rename.
  • ERef<T> = T | PromiseLike<T> (from @endo/eventual-send) is a widening of Promise at call sites (passing a Promise still works), but narrows what implementors can assume about what they receive — a subtlety of TypeScript's structural subtyping with interfaces.

Upgrade Considerations

release notes included

turadg and others added 6 commits April 8, 2026 10:14
`load()` previously returned `Promise<unknown>`, forcing every caller
to assert the bundle shape with a cast. Now it returns a typed result
conditional on the `format` option:

- Omitted (default) → `Promise<BundleSourceResult<'endoZipBase64'>>`
- Specific format → `Promise<BundleSourceResult<format>>`
- Runtime-typed `ModuleFormat` → `Promise<BundleSourceResult<F>>` (the union)

The implementation in cache.js uses a generic `Opts` template parameter
that flows the format from the caller's options through to the return
type. The runtime is unchanged.

This unblocks 3 errors in @agoric/smart-wallet's test files where
`bundleCache.load(...)` results were previously typed as `unknown`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 8, 2026 19:15
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

🦋 Changeset detected

Latest commit: b199281

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@endo/bundle-source Minor
@endo/daemon Patch
@endo/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Upgrades the repository to TypeScript 6 and resolves the resulting type-checking issues, including more precise public type definitions and faster repo-wide TS checks via incremental compilation.

Changes:

  • Bump TypeScript dependency to ~6.0.2 via Yarn catalogs and update lockfile/package manifests accordingly.
  • Enable TS incremental compilation via the shared tsconfig.eslint-base.json and ensure root tsconfig.json covers test paths.
  • Fix TS6-checking fallout across packages (JSDoc typings, catch variable typing, stricter generics) and refine a few public .d.ts APIs (notably @endo/daemon and @endo/bundle-source).

Reviewed changes

Copilot reviewed 119 out of 123 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
yarn.lock Updates workspace TypeScript dependency and adds TS 6.0.2 resolutions
tsconfig.json Ensures test paths are included by removing **/test exclusion
tsconfig.eslint-base.json Enables incremental compilation and adjusts base compiler options
packages/zip/src/buffer-reader.js JSDoc typing fix for WeakMap access
packages/zip/package.json Uses catalog TypeScript dev dependency
packages/where/package.json Uses catalog TypeScript dev dependency
packages/test262-runner/package.json Uses catalog TypeScript dev dependency
packages/stream/test/stream.test.js Catch variable typed for TS6
packages/stream/test/map.test.js Catch variable typed for TS6
packages/stream/package.json Uses catalog TypeScript dev dependency
packages/stream-types-test/package.json Uses catalog TypeScript dev dependency
packages/stream-node/package.json Uses catalog TypeScript dev dependency
packages/skel/package.json Uses catalog TypeScript dev dependency
packages/ses/test/lockdown.test.js Adjusts assertion to avoid TS void/undefined friction
packages/ses/test/import-stack-traces.test.js Catch variable typed for TS6
packages/ses/test/error/aggregate-error.test.js Catch variable typed for TS6 AggregateError usage
packages/ses/test/_package/test.js Updates test import path
packages/ses/test/_ava-after-install-unsafe.js Catch variable typed for TS6
packages/ses/test/_ava-after-install-safe.js Catch variable typed for TS6
packages/ses/src/permits.js Catch variable typed for TS6
packages/ses/src/error/tame-error-constructor.js JSDoc and Reflect.apply call-site typing adjustment
packages/ses/src/compartment.js JSDoc/type refinements around constructor args/this
packages/ses/src/commons.js Catch variable typed more precisely
packages/ses/src/cauterize-property.js Catch variable typing for logging
packages/ses/src/assert-sloppy-mode.js Uses Function('return this')() for sloppy-mode detection under TS6
packages/ses/package.json Uses catalog TypeScript dev dependency
packages/ses-ava/test/panic.test.js Catch variable typed for TS6 Object.hasOwn
packages/ses-ava/package.json Uses catalog TypeScript dev dependency
packages/promise-kit/package.json Uses catalog TypeScript dev dependency
packages/promise-kit/index.js Adds explicit Promise type assertion for TS6
packages/patterns/test/mismatch-stack-demo.test-verbose.js Catch variable typed for TS6
packages/patterns/test/mismatch-stack-demo.test-consise.js Catch variable typed for TS6
packages/patterns/src/keys/checkKey.js Avoids WeakSet primitive key runtime error; improves typings
packages/patterns/package.json Uses catalog TypeScript dev dependency
packages/path-compare/package.json Uses catalog TypeScript dev dependency
packages/pass-style/test/passStyleOf.test.js Catch variable typed for TS6; stack assignment cast
packages/pass-style/src/types.test-d.ts Updates type expectations for TS6
packages/pass-style/src/error.js Catch variable typed more precisely
packages/pass-style/package.json Uses catalog TypeScript dev dependency
packages/panic/package.json Uses catalog TypeScript dev dependency
packages/ocapn/test/handoffs.test.js Catch variable typed for TS6; message access cast
packages/ocapn/src/codecs/ocapn-pass-style.js Catch variable typed for TS6 in error message
packages/ocapn/package.json Uses catalog TypeScript dev dependency
packages/ocapn-noise/package.json Uses catalog TypeScript dev dependency
packages/netstring/package.json Uses catalog TypeScript dev dependency
packages/nat/package.json Uses catalog TypeScript dev dependency
packages/module-source/package.json Uses catalog TypeScript dev dependency
packages/memoize/package.json Uses catalog TypeScript dev dependency
packages/marshal/test/marshal-testing.test.js Adjusts default param typing under TS6
packages/marshal/src/rankOrder.js Refines Map/WeakMap typing for TS6
packages/marshal/src/dot-membrane.js Adjusts default param typing under TS6
packages/marshal/package.json Uses catalog TypeScript dev dependency
packages/lp32/package.json Uses catalog TypeScript dev dependency
packages/init/src/node-async-local-storage-patch.js JSDoc typing fix for WeakMap access
packages/init/package.json Uses catalog TypeScript dev dependency
packages/import-bundle/package.json Uses catalog TypeScript dev dependency
packages/immutable-arraybuffer/package.json Uses catalog TypeScript dev dependency
packages/harden/package.json Uses catalog TypeScript dev dependency
packages/far/package.json Uses catalog TypeScript dev dependency
packages/exo/test/vstorage.test-d.ts Updates type expectations under TS6
packages/exo/test/types-typed-guarded.test-d.ts Adjusts test call-site to satisfy TS6 typing
packages/exo/package.json Uses catalog TypeScript dev dependency
packages/eventual-send/src/handled-promise.js Catch variable typed for TS6 annotateError
packages/eventual-send/package.json Uses catalog TypeScript dev dependency
packages/evasive-transform/package.json Uses catalog TypeScript dev dependency
packages/eslint-plugin/package.json Uses catalog TypeScript dev dependency
packages/errors/package.json Uses catalog TypeScript dev dependency
packages/env-options/package.json Uses catalog TypeScript dev dependency
packages/daemon/test/serial-jobs.test.js Adjusts enqueued function types for TS6
packages/daemon/test/remote-control.test.js Adjusts dispose callback typing under TS6
packages/daemon/test/multimap.test.js Adds array typing cast for TS6 inference
packages/daemon/test/locator.test.js Adds typing casts for TS6 inference
packages/daemon/test/formula-type.test.js Adds typing cast for TS6 inference
packages/daemon/test/deferred-tasks.test.js Provides required param to execute under TS6 typing
packages/daemon/src/types.d.ts Tightens/updates public daemon types for TS6 conformance
packages/daemon/src/remote-control.js Updates JSDoc types to ERef/unknown under TS6
packages/daemon/src/mail.js Casts id to branded FormulaIdentifier for updated types
packages/daemon/src/directory.js Refactors lookup chain to satisfy TS6 typing
packages/daemon/src/daemon.js Makes getIdForRef safe for non-object inputs; typing update
packages/daemon/src/daemon-node-powers.js Catch variable typed for TS6 in error message
packages/daemon/src/context.js Marks cancel reason param optional in JSDoc
packages/daemon/package.json Uses catalog TypeScript dev dependency
packages/compartment-mapper/test/stack.test.js Catch variable typed for TS6; stack logging made explicit
packages/compartment-mapper/test/source-url-rewrite.test.js Catch variable typed for TS6; stack logging made explicit
packages/compartment-mapper/test/scaffold.js Catch variable typed for TS6 when passing to callback
packages/compartment-mapper/test/project-fixture.js Fixes return type JSDoc under TS6
packages/compartment-mapper/test/dynamic-require.test.js Catch variable typed for TS6; handles optional cause
packages/compartment-mapper/test/bundle.test.js Catch variable typed for TS6; stack stringification for checks
packages/compartment-mapper/src/node-powers.js Improves ErrnoException typing; message access cast
packages/compartment-mapper/src/map-parser.js Ensures thrown error/cause are typed as Error
packages/compartment-mapper/src/import-hook.js Ensures deferred errors are typed as Error
packages/compartment-mapper/src/digest.js Ensures thrown error/cause are typed as Error
packages/compartment-mapper/src/compartment-map.js Ensures collected errors are typed as Error
packages/compartment-mapper/package.json Uses catalog TypeScript dev dependency
packages/common/package.json Uses catalog TypeScript dev dependency
packages/common/apply-labeling-error.js Ensures thrown labeled error is typed as Error
packages/cli/test/demo/sending-messages.js Updates JSDoc type import specifier for TS6 resolution
packages/cli/test/demo/names-in-transit.js Updates JSDoc type import specifier for TS6 resolution
packages/cli/test/demo/mailboxes-are-symmetric.js Updates JSDoc type import specifier for TS6 resolution
packages/cli/test/demo/doubler-agent.js Updates JSDoc type import specifier for TS6 resolution
packages/cli/test/demo/counter-example.js Updates JSDoc type import specifier for TS6 resolution
packages/cli/test/_with-context.js Updates JSDoc type import specifier for TS6 resolution
packages/cli/test/_section.js Aligns JSDoc types with updated test helper types
packages/cli/test/_daemon-context.js Updates JSDoc type import specifier for TS6 resolution
packages/cli/package.json Uses catalog TypeScript dev dependency
packages/cjs-module-analyzer/package.json Uses catalog TypeScript dev dependency
packages/cjs-module-analyzer/index.js Casts thrown parse error to annotate message/loc under TS6
packages/check-bundle/package.json Uses catalog TypeScript dev dependency
packages/captp/src/captp.js Adds missing JSDoc type and adjusts error handling casts
packages/captp/package.json Uses catalog TypeScript dev dependency
packages/cache-map/package.json Uses catalog TypeScript dev dependency
packages/bundle-source/src/types.ts Makes BundleCache.load() return type conditional on format
packages/bundle-source/src/endo.js Adds ParserImplementation type annotations
packages/bundle-source/package.json Uses catalog TypeScript dev dependency
packages/bundle-source/cache.js Adds type assertions and refines load() typing/args defaults
packages/benchmark/src/benchmark.js Catch variable typed for TS6 in log message
packages/benchmark/package.json Uses catalog TypeScript dev dependency
packages/base64/package.json Uses catalog TypeScript dev dependency
package.json Uses catalog TypeScript dev dependency
.yarnrc.yml Updates TypeScript catalog version to ~6.0.2
.gitignore Ignores Claude worktrees directory
.changeset/daemon-ts6-type-precision.md Documents daemon public type tightening for TS6
.changeset/bundle-source-cache-load-types.md Documents bundle-source load() conditional return type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@turadg
Copy link
Copy Markdown
Member Author

turadg commented Apr 8, 2026

This change is part of the following stack:

Change managed by git-spice.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 118 out of 122 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +97 to +101
Opts extends { format: infer F }
? F extends ModuleFormat
? BundleSourceResult<F>
: BundleSourceResult<'endoZipBase64'>
: BundleSourceResult<'endoZipBase64'>
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional return type for BundleCache.load won’t behave as described for callers that pass an options variable typed as BundleCacheOperationOptions (where format is optional): BundleCacheOperationOptions does not satisfy { format: ... }, so the return type collapses to the default 'endoZipBase64' even though options.format may be set at runtime. Consider using overloads (no options → default; options with format: FBundleSourceResult<F>; otherwise → BundleSourceResult<ModuleFormat>) or changing the conditional to account for optional/undefined formats (e.g. match { format?: infer F } and use Extract<F, ModuleFormat>).

Copilot uses AI. Check for mistakes.
Comment on lines +374 to +377
* Opts extends { format: infer F }
* ? F extends ModuleFormat
* ? import('./src/types.js').BundleSourceResult<F>
* : import('./src/types.js').BundleSourceResult<'endoZipBase64'>
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This JSDoc return-type conditional has the same issue as the exported BundleCache.load type: checking Opts extends { format: ... } will treat BundleCacheOperationOptions (where format is optional) as the “no format” case, narrowing the return type to the default even when a runtime format may be present. Align this with the fixed signature (likely via overload-style JSDoc or by matching format? and extracting ModuleFormat).

Suggested change
* Opts extends { format: infer F }
* ? F extends ModuleFormat
* ? import('./src/types.js').BundleSourceResult<F>
* : import('./src/types.js').BundleSourceResult<'endoZipBase64'>
* Opts extends { format?: infer F }
* ? Extract<F, ModuleFormat> extends never
* ? import('./src/types.js').BundleSourceResult<'endoZipBase64'>
* : import('./src/types.js').BundleSourceResult<Extract<F, ModuleFormat>>

Copilot uses AI. Check for mistakes.
@boneskull
Copy link
Copy Markdown
Member

IIRC they made strict mode the default in TS6. We could set strict: false and avoid a lot of these changes, yeah? Not saying that's desirable or suggesting that's what we should be doing, as strict mode is generally a good thing; just wanted to mention it.

@turadg
Copy link
Copy Markdown
Member Author

turadg commented Apr 8, 2026

IIRC they made strict mode the default in TS6. We could set strict: false and avoid a lot of these changes, yeah? Not saying that's desirable or suggesting that's what we should be doing, as strict mode is generally a good thing; just wanted to mention it.

You're right, strict is now true by default. I'd prefer to conform but if there's a request to deliver the TS 6 bump with "strict: false" and follow up with the strict changes later I would agree to that (with some chagrin).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants