[ethers-v5] Error generating code for events with tuples
See original GitHub issueWhen an event definition includes a tuple among its arguments, the generated code in the corresponding .d.ts
file is invalid for the ethers-v5 target.
I have reproduced this problem using the latest code from the master branch (matches tag @typechain/ethers-v5@6.0.3
). I have simply added an event with a tuple to the examples/ethers-v5/abi/dai.json
file, as shown in this fork’s commit.
Namely, I included an event definition as such in examples/ethers-v5/abi/dai.json
:
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "src", "type": "address" },
{
"indexed": false,
"name": "data",
"type": "tuple",
"components": [
{ "name": "index", "type": "uint256" },
{ "name": "name", "type": "string" }
]
}
],
"name": "Tuple",
"type": "event"
}
Then the generated code in the examples/ethers-v5/types/ethers-contracts/Dai.d.ts
is:
Tuple(
src: string | null,
data: null
): TypedEventFilter<
[string, [BigNumber, string], { index: BigNumber; name: string }] & {
src: string;
data: [BigNumber, string] & { index: BigNumber; name: string };
}
>;
Which leads to the following error when running yarn typecheck
within examples/ethers-v5
$ yarn typecheck
yarn run v1.22.5
$ tsc --noEmit
types/ethers-contracts/Dai.d.ts:837:8 - error TS2314: Generic type 'TypedEventFilter<EventArgsArray, EventArgsObject>' requires 2 type argument(s).
837 ): TypedEventFilter<
~~~~~~~~~~~~~~~~~
838 [string, [BigNumber, string], { index: BigNumber; name: string }] & {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
841 }
~~~~~~~
842 >;
~~~~~
Found 1 error.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
At first glance, it seems to me that the correct output would be to switch the position of ,
and &
as follows:
Tuple(
src: string | null,
data: null
): TypedEventFilter<
[string, [BigNumber, string]& { index: BigNumber; name: string }] , { // <---- switched `&` and `,` here
src: string;
data: [BigNumber, string] & { index: BigNumber; name: string };
}
>;
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top GitHub Comments
Released as https://github.com/ethereum-ts/TypeChain/releases/tag/%40typechain/ethers-v5%406.0.4
@zemse don’t worry - I am on it. Focus on your exams so you have more time to help us in the future 😆