fix(core): prevent distributive conditional type in GetClientReturnType#5136
Open
quentin-lian wants to merge 1 commit into
Open
fix(core): prevent distributive conditional type in GetClientReturnType#5136quentin-lian wants to merge 1 commit into
quentin-lian wants to merge 1 commit into
Conversation
Wrap the conditional in `GetClientReturnType` with tuple types to stop TypeScript from distributing over multi-chain `resolvedChainId` unions. This allows the client returned by `getClient` to be passed directly into viem actions (waitForTransactionReceipt, getBlock, getTransaction) when the config has multiple chains. Closes wevm#3635
|
@quentin-lian is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: c5e7e1d The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wraps the conditional in
GetClientReturnTypewith tuple types ([resolvedChainId] extends [...]) to prevent TypeScript from distributing over multi-chainresolvedChainIdunions.Without this fix,
getClient(config)on a multi-chain config returnsClient<_, chainA> | Client<_, chainB>(a union of clients), which is incompatible with viem actions that expectClient<Transport, chain>. With the fix, it returnsClient<_, chainA | chainB>(a single client with a union chain), which TypeScript can match correctly.Changes
packages/core/src/actions/getClient.ts— one-line fix:[resolvedChainId] extends [config['chains'][number]['id']]packages/core/src/actions/getClient.test-d.ts— type regression test coveringwaitForTransactionReceipt,getBlock, andgetTransactionwith a two-chain config.changeset/fix-getClient-multichain-type.md— patch changeset for@wagmi/coreValidation
pnpm --filter @wagmi/core check:typespasses with no errorsbiome checkpassesCloses #3635