dethcrypto / dethcrypto/TypeChain

In the web3 target, should allEvents have a version that doesn't specify options?

Open
#791 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.8k
Forks
376
PR merge metrics
No merged PRs in 30d

Description

In the web3 target, the contract's `events` member specifies each event twice, with and without the optional options parameter first, followed by an `allEvents` item that has only the latter:

````ts
MyFirstEvent(cb?: Callback): EventEmitter;
MyFirstEvent(options?: EventOptions, cb?: Callback): EventEmitter;

MySecondEvent(cb?: Callback): EventEmitter;
MySecondEvent(options?: EventOptions, cb?: Callback): EventEmitter;
//...
allEvents(options?: EventOptions, cb?: Callback): EventEmitter;
````

This threw me for a bit of a loop because I had a type definition matching the majority of those events and checked for `events` to be a string-indexed object collecting those, and `allEvents` broke this pattern so it failed typechecking. I think I was able to get a workaround by modifying the type definition to fit allEvents and the others fit that too, but it makes me wonder why that difference is there and if it really should be, or if an additional line should be emitted, just before the last of those:
`allEvents(cb?: Callback): EventEmitter;`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.