fix: simplify smart account client return type#511
Open
samsamtrum wants to merge 1 commit into
Open
Conversation
|
pull Bot
pushed a commit
to Hawthorne001/permissionless.js
that referenced
this pull request
Jul 9, 2026
Checking a client created by createSmartAccountClient, createPimlicoClient, or createPasskeyServerClient against its bare alias (e.g. useQuery<SmartAccountClient>) forced TypeScript to structurally expand the full action surface on every call site: ~82s / 481k type instantiations in the issue's reproduction. The client aliases now use an inline mapped-type body over a private *Inner alias, with variance annotations on the type parameters (the same pattern viem ships in SimulateContractReturnType, wevm/viem#2557). Both sides of a comparison then carry the alias's identity, so tsc compares instantiations argument-by-argument instead of expanding them: the issue's repro drops to 0.44s / 149k instantiations. rpcSchema is deliberately left unannotated so a pairwise mismatch falls back to the structural check rather than rejecting assignments that compile today. Return-type precision is unchanged. The mapped types must stay inline: extracting them into a shared helper (e.g. Flatten<T>) re-attaches the helper's alias identity instead and restores the slowdown (measured: 444k instantiations, no improvement). The type-consumer fixture now guards all of this against the packed tarball: Equal-assertions that account/chain/client stay exactly inferred (what PR pimlicolabs#511 would have widened), bare-alias assignability (which fails loudly if the variance fast path ever hard-rejects), and custom-rpcSchema fallback for all three clients. Closes pimlicolabs#500. Supersedes pimlicolabs#511. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
createSmartAccountClientoverload to return the exportedSmartAccountClientalias directly.transport/chain/account/client/rpcSchemainstantiation at the call site, which is the expensive assignability path described in createSmartAccountClient` causes ~82s type-checking bottleneck due to deep generic inference #500.Closes #500.
Verification
bun install --frozen-lockfilegit diff --checkbun run build:permissionless:typeswas started but did not finish within a 120s local timeout on this machine.bun run lintcurrently fails on pre-existing repository warnings/errors unrelated to this change (for example existingnoExplicitAnydiagnostics inpackages/mock-paymaster,packages/wagmi, tests, and an existingClient<any, ...>type in this file).