You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Set up TS project
Attempt to construct Web3 instance with non-standard provider
The text was updated successfully, but these errors were encountered:
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 basicProvider
interface which all providers must implement. Using a generic type parameter would be even more ideal, because it means properties likecurrentProvider
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
Web3
instance with non-standard providerThe text was updated successfully, but these errors were encountered: