ethereum-optimism / ethereum-optimism/actions
Replace all `any` types with specific types
- Dominant language
- TypeScript
- Stars
- 32
- Forks
- 25
- Avg merge
- 10h 20m
- Merged PRs (30d)
- 16
Description
## Problem
There are ~51 `@typescript-eslint/no-explicit-any` warnings across the SDK and demo backend. Using `any` bypasses type checking and can hide bugs.
## Scope
**SDK source files:**
- `lend/providers/aave/sdk.ts`
- `lend/providers/morpho/api.ts`
- `lend/providers/morpho/sdk.ts`
- `services/__mocks__/MockChainManager.ts`
**SDK test files:**
- `lend/core/__tests__/LendProvider.test.ts`
- `lend/providers/morpho/__tests__/MorphoLendProvider.test.ts`
- `services/tokenBalance.spec.ts`
- `swap/providers/uniswap/__tests__/sdk.test.ts`
- `utils/assets.test.ts`
- `wallet/react/wallets/hosted/dynamic/__tests__/DynamicWallet.spec.ts`
- `wallet/react/wallets/hosted/privy/__tests__/PrivyWallet.spec.ts`
- `wallet/core/wallets/smart/default/__tests__/DefaultSmartWallet.spec.ts`
**Demo backend:**
- `packages/demo/backend/src/helpers/validation.spec.ts`
- `packages/demo/backend/src/services/lend.spec.ts`
- `packages/demo/backend/src/services/swap.spec.ts`
## Guidelines
Follow existing patterns in the codebase:
- **External API responses** — use `unknown` and narrow with type guards or assertions, not `any`. See `utils/assets.ts` for examples of typed return values.
- **Mock objects in tests** — use `as unknown as SpecificType` instead of `as any`. See `swap/__mocks__/MockSwapProvider.ts` for the pattern:
```ts
const publicClient = { readContract: vi.fn() } as unknown as PublicClient
```
- **Generic callbacks and parameters** — use `unknown` with type narrowing, or define a proper generic. Prefer `Record` over `Record`.
- **viem contract call returns** — cast to the expected tuple type. See `encoding/v2.ts`:
```ts
return (amounts as bigint[])[1]
```
- **Error handling** — use `unknown` for catch parameters:
```ts
catch (error: unknown) { ... }
```
- **JSON/API data** — define response interfaces rather than using `any`. See `types/swap/base.ts` and `types/lend/base.ts` for examples.
## Verification
After replacing all `any` types, `pnpm lint` should show 0 `no-explicit-any` warnings. Run `pnpm typecheck` to confirm no type errors were introduced.
Contributor guide
Research direction
Start by running pnpm lint and reviewing the listed SDK, test, and demo backend files, using utils/assets.ts, swap/__mocks__/MockSwapProvider.ts, encoding/v2.ts, and the lend and swap type files as reference. Replace the scoped any usages according to the existing patterns, then confirm pnpm lint reports zero no-explicit-any warnings and pnpm typecheck passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, testing-qa
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100