Skip to content

Commit

Permalink
fix(types): properly augment ethers BigNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Oct 13, 2022
1 parent 0649637 commit cae96b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lib/*"
],
"scripts": {
"build": "tsc",
"build": "tsc --build tsconfig.build.json",
"clean": "rm -rf ./lib/",
"cm": "cz",
"lint": "eslint ./src --fix",
Expand Down
12 changes: 7 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const RAY_PERCENT_RATIO = RAY.div(PERCENT);
const HALF_RAY_PERCENT_RATIO = RAY_PERCENT_RATIO.div(2);

declare module "ethers" {
class BigNumber {
interface BigNumber {
min: (other: BigNumberish) => BigNumber;
max: (other: BigNumberish) => BigNumber;
sum: (others: BigNumberish[]) => BigNumber;
Expand Down Expand Up @@ -50,11 +50,13 @@ declare module "ethers" {
rayToPercent: () => BigNumber;
rayToWad: () => BigNumber;
formatWad: () => string;
}

static pow10: (power: BigNumberish) => BigNumber;
static parsePercent: (value: string) => BigNumber;
static parseWad: (value: string) => BigNumber;
static parseRay: (value: string) => BigNumber;
namespace BigNumber {
let pow10: (power: BigNumberish) => BigNumber;
let parsePercent: (value: string) => BigNumber;
let parseWad: (value: string) => BigNumber;
let parseRay: (value: string) => BigNumber;
}
}

Expand Down
7 changes: 7 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "src"
},
"include": ["src"]
}

0 comments on commit cae96b4

Please sign in to comment.