-
Notifications
You must be signed in to change notification settings - Fork 725
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
EVM property doesn't contain event emitter properties #2181
Comments
Why not make the If the above type guard is required we'll just write our own |
If we do that, we require the interface to implement those events, which is not exactly necessary to work with our libraries. For a non-runtime fix see #2182 |
Your Generics solution looks to be more useful to Ganache! |
That's great, in that case I will continue on that tomorrow (unless @acolytec3 or someone else has reservations here). We can most likely also solve the problem with the |
As identified by the Ganache team, the current
vm.evm
property is typed asEVMInterface | EVM
and this leads to DX challenges whereyields a type error in the IDE because Typescript can't infer the type
EVM
forvm.evm
due to theEVMInterface
not extending theEventEmitter
class. For users that want to access thestep
event and other the other public properties/events of theEVM
class while referencing it from the VM, they are currently forced to do:each time they want to access something exposed by the
EVM
class but not included in the interface. The "Typescript Way" ™️ of handling stuff like this is through a type guard, I propose adding a type guard as a static method on the EVM class to allow teams to quickly access the type of the EVM property once at the start of their code and then not have to worry about typecasting.It would look something like this:
and be used something like:
WDYGT?
cc: @davidmurdoch @holgerd77 @jochem-brouwer
The text was updated successfully, but these errors were encountered: