Definitelytyped: [@types/web3] Add static Utils property to Web3 class

Created on 3 Aug 2018  路  10Comments  路  Source: DefinitelyTyped/DefinitelyTyped

Hi all,

As I know, utility functions are also exposed on the Web3 class as well as on instance of Web3. But I've found Utils only in an instance.

What did you do?

import Web3 = require('web3');
const randomHex = Web3.utils.randomHex(10);

What happened?

Typescript won't compile because Web3 does not have a key utils.

What should happen?

Typescript should compile because Web3 has a key utils.

What is missing:

  • static Web3.utils property;

Others

  • [x] I tried using the @types/web3 package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @simon-jentzsch, @nitzantomer, @zurbo, @yxliang01, @phra, @naddison36, @icaroharry, @linusnorton, @jpeletier, @anneau, @matrushka, @andrevmatos, @levino, @zlumer

Most helpful comment

Gonna look into this over the weekend.

All 10 comments

Gonna look into this over the weekend.

Typically web3. Why on earth should these utils be at two places?

Back to the topic at hand: Should be fixed. Will you provide a PR @archangel-irk ?

@Levino Yes, I'm going to make the PR.

Please review #27898. This should fix the problem.

To clarify:

What did you do?

import Web3 = require('web3')
const randomHex = Web3.utils.randomHex(10)

Please note: Web3 not web3

What happened?

Typescript won't compile because Web3 does not have a key utils.

What should happen?

Typescript should compile because Web3 has a key utils.

@archangel-irk Maybe you want to update your issue based on my clarification above.

@Levino updated

I'm going to make a PR today.

Updated:
Please review PR #27963

So in according to recent changes we have two identical PR's #27898 and #27963

27898 closed, let's focus on #27963

Was this page helpful?
0 / 5 - 0 ratings