Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wbt opened this issue Nov 3, 2022 · 0 comments

Comments

@wbt
Copy link
Contributor

wbt commented Nov 3, 2022

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:

    MyFirstEvent(cb?: Callback<MyFirstEvent>): EventEmitter;
    MyFirstEvent(options?: EventOptions, cb?: Callback<MyFirstEvent>): EventEmitter;

    MySecondEvent(cb?: Callback<MySecondEvent>): EventEmitter;
    MySecondEvent(options?: EventOptions, cb?: Callback<MySecondEvent>): EventEmitter;
    //...
    allEvents(options?: EventOptions, cb?: Callback<EventLog>): 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<EventLog>): EventEmitter;.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant