Skip to content

fix: simplify smart account client return type#511

Open
samsamtrum wants to merge 1 commit into
pimlicolabs:mainfrom
samsamtrum:fix-smart-account-client-return-type
Open

fix: simplify smart account client return type#511
samsamtrum wants to merge 1 commit into
pimlicolabs:mainfrom
samsamtrum:fix-smart-account-client-return-type

Conversation

@samsamtrum

Copy link
Copy Markdown

Summary

Closes #500.

Verification

  • bun install --frozen-lockfile
  • git diff --check
  • bun run build:permissionless:types was started but did not finish within a 120s local timeout on this machine.
  • bun run lint currently fails on pre-existing repository warnings/errors unrelated to this change (for example existing noExplicitAny diagnostics in packages/mock-paymaster, packages/wagmi, tests, and an existing Client<any, ...> type in this file).

@changeset-bot

changeset-bot Bot commented May 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: bf07ef9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

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>
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.

createSmartAccountClient` causes ~82s type-checking bottleneck due to deep generic inference

1 participant