-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow creation without the new
keyword
#216
Comments
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) |
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
The text was updated successfully, but these errors were encountered: