Skip to content

Incorrect types returned from some generated read contract hooks #5017

@iceanddust

Description

@iceanddust

Check existing issues

Describe the bug

With the changes implemented in the Wagmi@3.3.2 update, some generated read contract hooks coming from the @wagmi/cli package started returning incorrect types.

See the minimal reproducible example:
For the ABI generated, the return type of the ilks function should be
readonly [bigint, rate: bigint, bigint, bigint, bigint]
However, that type is only returned by the specific react contract function hook (useReadMcdVatIlks), if I use the more general read contract hook (useReadMcdVat), passing the same function name and argument, the return type is
bigint | readonly [bigint, rate: bigint, bigint, bigint, bigint]

Link to Minimal Reproducible Example

https://stackblitz.com/edit/new-wagmi-t3ymsfba?file=src%2FApp.tsx

Steps To Reproduce

In case you want to regenerate the ABI and hooks:

  • Replace the etherscan API key in the wagmi.config.ts file
  • Run pnpm wagmi generate

Then,

  • Check the App.tsx file and look at the return type of the data prop of both hooks. They should be the same, but they're not

What Wagmi package(s) are you using?

wagmi

Wagmi Package(s) Version(s)

3.5.0

Viem Version

2.46.3

TypeScript Version

5.9.3

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions