MikeMcl / decimal.js

An arbitrary-precision Decimal type for JavaScript
http://mikemcl.github.io/decimal.js
MIT License
6.35k stars 480 forks source link

question:Value of type 'typeof Decimal' is not callable. Did you mean to include 'new'? #232

Open web-shenjin opened 7 months ago

web-shenjin commented 7 months ago

image

please how resolve?

MikeMcl commented 7 months ago

Try putting the following line above your code:

declare function Decimal(n: string | number | Decimal): Decimal;

Does that work? It's been a while since I've used typescript.

Or just change the code to:

settlementNumber = new Decimal(settlementNumber).add(v.settlementNumber).toNumber();

Same issue as #216. The decimal.d.ts file needs to be amended to support calling Decimal without using new.

jakub791 commented 3 months ago

The decimal.d.ts file needs to be amended to support calling Decimal without using new.

Actually why is it even allowed to call it as a function, without new? Now it's probably just backwards compatibility, but what was the use case at first?