ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

Fix types for strict nulls

Open nezed opened this issue 3 years ago • 2 comments

This PR fixes following errors caused by strict null checks and which i was unable to suppress with "skipLibCheck": true tsc option.

node_modules/@ethersproject/abstract-provider/src.ts/index.ts:246:13 - error TS2322: Type 'BigNumber' is not assignable to type 'null'.

246             maxPriorityFeePerGas = BigNumber.from("2500000000");
                ~~~~~~~~~~~~~~~~~~~~

node_modules/@ethersproject/abstract-provider/src.ts/index.ts:247:13 - error TS2322: Type 'BigNumber' is not assignable to type 'null'.

247             maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
                ~~~~~~~~~~~~

node_modules/@ethersproject/abstract-provider/src.ts/index.ts:247:59 - error TS2345: Argument of type 'null' is not assignable to parameter of type 'BigNumberish'.

247             maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
                                                              ~~~~~~~~~~~~~~~~~~~~

nezed avatar Jul 14 '22 17:07 nezed

If you are skipping lib checks, there shouldn’t be any need to change the library. Why is this necessary?

I’d prefer not to make any changes like this, as v6 has strict null checking and I’m trying to reduce changes to v5 so I can focus on v6.

ricmoo avatar Jul 14 '22 18:07 ricmoo

skipLibCheck is ignored on root files (like test specs), so only option that i have to do to suppress this error is to patch a package in postinstall script.

I think its ok to close this PR if v6 comes soon 👍

nezed avatar Jul 14 '22 18:07 nezed