-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
The error from useWeb3Context is of type Error, which doesn't have a code property - leads to TypeScript warning #32
Comments
hey @pcowgill, thanks for the report! makes sense, i override that error locally with this snippet: https://github.com/NoahZinsmeister/web3-react/blob/latest/src/declarations.ts#L20. looking at MDN though, it seems like i'm going to keep the issue open and experiment with this in the next version. |
@NoahZinsmeister Thanks for the example of how to override it! Agreed, I think |
Also, you can subclass errors so that they’ll have name set automatically in the case of a frequently used “error code” |
🙏 that sounds perfect, i'll try that! |
@NoahZinsmeister In the meantime, do you know of any examples of an app using this library making use of those or similar declarations? Thanks! |
This seems to work for an app using this lib:
(The |
going to close this, as v6 uses custom errors which can be checked with |
When using
useWeb3Context
fromweb3-react
in a TypeScript-flavored create-react-app app, this error is shown:Property 'code' does not exist on type 'Error'. ts(2339)
Here's a snippet to reproduce it:
The text was updated successfully, but these errors were encountered: