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

Web3 constructor does not accept custom/non-standard providers in TypeScript #3380

Closed
smithki opened this issue Feb 19, 2020 · 2 comments · Fixed by #3451
Closed

Web3 constructor does not accept custom/non-standard providers in TypeScript #3380

smithki opened this issue Feb 19, 2020 · 2 comments · Fixed by #3451
Labels
1.x 1.0 related issues Good First Issue Great to learn the internals of web3.js Types Incorrect or missing types

Comments

@smithki
Copy link

smithki commented Feb 19, 2020

Overview

Related to #2266

There should be a way to overload the TypeScript definition of Web3 constructor to accept custom providers. I've tried everything, even declaration merging won't work. The easiest solution I foresee, which would not be a breaking change, is to provide a basic Provider interface which all providers must implement. Using a generic type parameter would be even more ideal, because it means properties like currentProvider could be strongly typed, even if they are custom/non-standard.

Right now the only workaround is to cast the provider to any, which is not ideal.

Steps to reproduce the behavior

  1. Set up TS project
  2. Attempt to construct Web3 instance with non-standard provider
@nivida nivida added 1.x 1.0 related issues Types Incorrect or missing types Good First Issue Great to learn the internals of web3.js labels Feb 20, 2020
@Himanshu-Pandey
Copy link

@nivida @smithki I am picking it up. Will update once I am done :)

@odanado
Copy link
Contributor

odanado commented Apr 1, 2020

This issue hasn't been updated in a month, so I created #3451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Good First Issue Great to learn the internals of web3.js Types Incorrect or missing types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants