Replace any types with specific types across SDK and demo packages#339
Open
daatsuka wants to merge 2 commits into
Open
Replace any types with specific types across SDK and demo packages#339daatsuka wants to merge 2 commits into
any types with specific types across SDK and demo packages#339daatsuka wants to merge 2 commits into
Conversation
👷 Deploy request for actions-ui pending review.Visit the deploys page to approve it
|
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.
This change sweeps through 23 files in
packages/sdk,packages/demo/backend, andpackages/demo/frontendto eliminate every@typescript-eslint/no-explicit-anysuppression. In the SDK source layer, the biggest wins are inlend/providers/morpho/api.tsandlend/providers/morpho/sdk.ts:fetchRewardsnow returns a properly typedMorphoVaultApiResponseinstead ofany, backed by four new interfaces (MorphoRewardAsset,MorphoReward,MorphoMarketAllocation,MorphoVaultState) that model the Morpho GraphQL schema.calculateBaseApy,calculateApyBreakdown, andcalculateRewardsBreakdowninsdk.tsreceive a structuralMorphoSdkVaultinterface instead ofany, and the inlineAccrualPositioncast is gone — the reducer callback andallocation.positionare now typed throughMorphoSdkAllocation/MorphoSdkPosition. Inaave/sdk.ts,calculateApyBreakdown'sformattedReserveparameter moves fromanyto{ supplyAPY?: string }. Over inutils/test.ts, the Anvil RPC calls (anvil_impersonateAccount/anvil_stopImpersonatingAccount) are handled via a structural cast onpublicClient.requestinstead of casting the method string toany, and the redundantas anyoncreateWalletClientis simply removed because viem's types already match.In test files the pattern is consistent: every
as anymock cast becomesas unknown as <ConcreteType>, where<ConcreteType>is derived from the function's actual return type — e.g.ReturnType<typeof getActions>,Awaited<ReturnType<typeof fetchAccrualVault>>,Context(from Hono),PublicClient,BundlerClient,Asset,SupportedChainId, orAwaited<ReturnType<typeof toCoinbaseSmartAccount>>. This two-step cast throughunknownis the standard TypeScript escape hatch when building partial mocks: it satisfies the compiler while still documenting the intended type at the call site. The Morpho API test (api.test.ts) adds narrowing guards (if (!vaultData) throw new Error('unreachable')) before property access so the non-null assertions are explicit rather than silently swallowed byany. TheDynamicWallet.spec.tserror-cause access switches from(err as any).causeto(err as Error & { cause?: Error }).cause, preserving type safety on the chained cause.The design intent is to make every
anyremoval a local, minimal change — introduce the narrowest structural interface that satisfies the call site, preferReturnType/Awaitedutility types over hand-rolled duplicates, and avoid pulling in heavy external type packages. The Solidity fileDeployMorphoMarket.s.solonly has a formatting adjustment that crept in from the linter pass. I ranpnpm typecheckandpnpm lintacross the entire monorepo after the changes, confirming zero type errors and that theno-explicit-anywarning count drops to zero in all touched files.Closes #337