TypeScript definition file should reflect that Accounts is the _default_ export, not a named export.
TypeScript compiler raises an error when attempting to import Accounts as the default export, but we reach a runtime TypeError if we import Accounts as a named export.
import { Accounts } from 'web3-eth-accounts';
new Accounts() // TypeScript does not complain
// => TypeError: "Accounts is not a constructor"
import Accounts from 'web3-eth-accounts';
new Accounts() // TypeScript complains with: "This expression is not constructable."
// => works at runtime...
Thanks for opening this issue! Have you followed our TS guidance here which does require additional configuration?
Btw.: We can't change this that easy because it would break many already existing projects.
Edit: Sorry, it is possible to change it in a non-breaking manner we would only have to export it named and as default from the same file.
Btw.: We can't change this that easy because it would break many already existing projects.
I see this as a _bug_, though. Considering the expected behavior does not currently work, I do not understand how it can be considered a breaking change. Thankfully, there is a workaround using declaration merging:
import { AccountsBase } from 'web3-core';
import Accounts from 'web3-eth-accounts';
declare module 'web3-eth-accounts' {
export default class Accounts extends AccountsBase {}
}
We are re-assessing this. There are a few inconsistencies within the deceleration files. Feel free to follow along on #3606 for updates
This issue has been automatically marked as stale because 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.
_bump_
This issue has been automatically marked as stale because 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.
_bump_
This issue has been automatically marked as stale because 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.
Most helpful comment
I see this as a _bug_, though. Considering the expected behavior does not currently work, I do not understand how it can be considered a breaking change. Thankfully, there is a workaround using declaration merging: