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-utils types not compatible with current @types/bn.js #2290

Closed
sebastianst opened this issue Feb 1, 2019 · 2 comments
Closed

web3-utils types not compatible with current @types/bn.js #2290

sebastianst opened this issue Feb 1, 2019 · 2 comments
Labels
Types Incorrect or missing types

Comments

@sebastianst
Copy link

With web3-utils 1.0.0-beta.41 and the current @types/bn.js 4.11.4 tsc cannot transpile because the bn.js declaration doesn't have a default export. The following error is thrown

node_modules/web3-utils/types/index.d.ts:23:8 - error TS1192: Module '"/home/.../node_modules/@types/bn.js/index"' has no default export.

23 import BigNumber from 'bn.js';
          ~~~~~~~~~


Found 1 error.
@sebastianst
Copy link
Author

It may be worth a try to use

/// <reference types="bn.js" />

instead, where BN is used in the web.js type declarations, and remove the definition of the BN class from web3-utils.

@joshstevens19
Copy link
Contributor

joshstevens19 commented Feb 1, 2019

Hey thanks for your issue!

This has been fixed in PR https://github.com/ethereum/web3.js/pull/2280/files

We have to require it else it doesn't work with strict mode (due to the bn.js typing's) so this was the best solution.

This will be released in the next release (should be early next week). A temp fix is to run a post-install script which replaces this line:

import BigNumber from 'bn.js'; > import BigNumber = require('bn.js');

and install @types/bn locally which you can remove once the release comes out.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Types Incorrect or missing types
Projects
None yet
Development

No branches or pull requests

2 participants