decimal.js icon indicating copy to clipboard operation
decimal.js copied to clipboard

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

Open web-shenjin opened this issue 1 year ago • 2 comments

image

please how resolve?

web-shenjin avatar Feb 01 '24 08:02 web-shenjin

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.

MikeMcl avatar Feb 01 '24 20:02 MikeMcl

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?

jakub791 avatar Jun 02 '24 12:06 jakub791