Open frec-kenneth opened 1 year ago
This issue has been raised before, I think.
There was some problem with it but I can't remember what it was.
I had a search through the repos, but I didn't see a specific mention. I don't know Typescript well enough to assert that it's non-problematic, so happy to close this issue if necessary. If someone has more certainty though, would love to learn.
Thanks for taking a look.
You can always create your own wrapper function and use that, like:
function decimal(value: string | number | Decimal) : Decimal {
return new Decimal(value)
}
// now you can use:
decimal(5)
// instead of:
new Decimal(5)
@frec-kenneth
Leave the issue open and I'll investigate further.
Decimal.js seems to support instance creation without the
new
keyword, ie:But the Typescript definitions do not permit it. Is this an intentional choice? If not, could we add support to Typescript definitions by overloading the Decimal class?
Adding this line to decimal.d.ts locally seems to have the desired effect.
decimal.js: 10.3.1 typescript: 4.9.3