MikeMcl / bignumber.js

A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
http://mikemcl.github.io/bignumber.js
MIT License
6.63k stars 743 forks source link

Breaking changes with > 9.1.0 #341

Closed gugu91 closed 1 year ago

gugu91 commented 1 year ago

Thanks for this awesome library, really grateful for all your work!

Just wanted to flag that this line is a breaking change from the standpoint of typescript.

The other breaking change is that BigNumber.dp() can now be null.

Thought I'd leave a tiny migration guide:

  1. How to handle null dp?
  2. What is the advised way of importing the full BigNumber type now?
gugu91 commented 1 year ago
  1. What is the advised way of importing the full BigNumber type now?

Just import the default export and everything should be ok

gugu91 commented 1 year ago
  1. How to handle null dp? Just check the value first (it's recommended you have strictNullChecks: true in your tsconfig.
const dp = value.dp()
if (dp === null) {
// NaN or Infinity
...
}