From d914ecdc894e60d30cb8db597d492465c20f500c Mon Sep 17 00:00:00 2001 From: Alex Kvak Date: Wed, 23 Jan 2019 15:42:35 +0300 Subject: [PATCH] [web3]: toWei does not accept number --- types/web3/index.d.ts | 1 + types/web3/utils.d.ts | 2 +- types/web3/web3-tests.ts | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/types/web3/index.d.ts b/types/web3/index.d.ts index 3b1fe0c562..0f80294f1a 100644 --- a/types/web3/index.d.ts +++ b/types/web3/index.d.ts @@ -19,6 +19,7 @@ // Donam Kim // Doug Kent // Daniel Zhou +// Alex Kvak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 diff --git a/types/web3/utils.d.ts b/types/web3/utils.d.ts index fa73791615..9889e68f5e 100644 --- a/types/web3/utils.d.ts +++ b/types/web3/utils.d.ts @@ -89,7 +89,7 @@ export default interface Utils { toDecimal(val: any): number; toHex(val: any): string; toUtf8(val: any): string; - toWei(val: string | number, unit?: Unit): string; + toWei(val: string, unit?: Unit): string; toWei(val: BigNumber, unit?: Unit): BigNumber; unitMap: any; } diff --git a/types/web3/web3-tests.ts b/types/web3/web3-tests.ts index d2c3c92302..9ff6734d4c 100644 --- a/types/web3/web3-tests.ts +++ b/types/web3/web3-tests.ts @@ -163,6 +163,9 @@ const shhPromise: Promise = web3.shh.generateSymKeyFromPassword("xyz"); // -------------------------------------------------------------------------- const weiStr: string = web3.utils.toWei("100", "gwei"); const weiBn: BigNumber = web3.utils.toWei(web3.utils.toBN("1")); +// $ExpectError +const weiNumber = web3.utils.toWei(100); + const rndHex: string = Web3.utils.randomHex(10); const sha3: string = web3.utils.soliditySha3(0, 1, "abc"); const fromWei1: BigNumber = web3.utils.fromWei(new BigNumber(1));