-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
fix: Fix typings export for web3-providers-ws #3215
Conversation
Hey @fmiras, does this fix what you mentioned me some time ago? |
Partially yes, but this same thing is happening with some other imports of Web3. In fact, with this we will have some modules without default export and other bunch of them within it. |
Thanks for your reply @fmiras ! @nivida @cgewecke, FYI, what is happning right now is that type declarations use named exports, and the actual js files just reassign Note that fixing this is a breaking change for TS users, but their current situation is kinda shitty. They are forced to do things like this unless they use import * as Web3 from 'web3';
import { Eth } from 'web3-eth';
const client: Eth = new (Web3 as any)(clientHost).eth; |
@alcuadrado Yes, but we have the required configurations documented here. It will run without doing anything special if those configuration properties are defined as documented. But yes you are right it’s probably worth to update our exports from our type definitions if such a change doesn't break existing DApps with those documented configuration properties set. @joshstevens19 What do you think about as creator of those type definitions? |
IMHO web3 should work out of the box with |
This PR has been automatically marked as stale beacause it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
The WebsocketProvider class is set as
module.exports
in https://github.com/ethereum/web3.js/blob/1.x/packages/web3-providers-ws/src/index.js#L417 which makes it adefault
export.Currently, if you use the typings published in v1.2.4 you will get an error like
TypeError: WebsocketProvider is not a constructor
when trying to use it.