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

change return type from "BigNumber" to "this" #369

Open ozum opened 5 months ago

ozum commented 5 months ago

The hard-coded return type "BigNumber" prevents subclasses from working correctly with TypeScript types when superclass methods are called.

See #368, this PR closes #368

Note: I didn't change the return type of static isBigNumber(value: any): value is BigNumber; because its name implies checking whether the instance is a specifically BigNumber. Also, it works in subclasses as expected because all subclasses are also instances of BigNumber.