question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

get value via event.args.EVENT_KEY in typescript does not work

See original GitHub issue

although it is undocumented but event.args actually can get event property via string instead of array, for example:

// solidity
event ValueChanged(address indexed author, string oldValue, string newValue);

function setValue(string value) public {
    emit ValueChanged(msg.sender, _value, value);
    _value = value;
}

// javascript
const tx = await contractWithSigner.setValue("I like turtles.");
const receipt = await tx.wait();
console.log(receipt.events[0].args.newValue)
// print "I like turtles."
console.log(receipt.events[0].args[2])
// same "I like turtles."

it works in javascript but does not work in typescript since args is defined as any[]:

export interface Event extends Log {
    args?: Array<any>;
   // ...
}

PR is on the way to fix it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ricmoocommented, Mar 27, 2020

I actually just ran into this same issue yesterday and have it fixed on my local version. I’ll push the change tomorrow. 😃

0reactions
ricmoocommented, Apr 4, 2020

Ok. I’ll close this issue too, but please re-open if you continue to have issues.

Thanks! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Types of parameters 'event' and 'event' are incompatible
I have a set of buttons, and I call these buttons in another component, but when I write the code, I have this...
Read more >
React events and TypeScript: a complete guide - Devtrium
Learn how to handle onClick, onChange, and many other events on React with TypeScript. It's a bit harder than you'd think but easy...
Read more >
Typed event dispatcher and event handlers #5211 - GitHub
The parameter would restrict the handler to only handle one kind of event, where the detail field's type would be determined by the...
Read more >
KeyboardEvent - Web APIs | MDN
Returns a boolean value that is true if the Alt ( Option or ⌥ on macOS) key was active when the key event...
Read more >
Forms and Events - React TypeScript Cheatsheets
Event that occurs whenever a form or form element gets/loses focus, a form element value is changed or the form is submitted. InvalidEvent,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found