Skip to content
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

Cannot create bignumber instance without new #251

Closed
jurosh opened this issue Nov 20, 2019 · 2 comments
Closed

Cannot create bignumber instance without new #251

jurosh opened this issue Nov 20, 2019 · 2 comments

Comments

@jurosh
Copy link

jurosh commented Nov 20, 2019

There is problem creating instance of bignumber in typescript (probably also in JavaScript)

import BigNumber from 'bignumber.js';
const bn = BigNumber('0.123');

There is error : Value of type 'typeof BigNumber' is not callable. Did you mean to include 'new'?

As per doc new keyword for creating instance of Bignumber should not be required.

@djmattyg007
Copy link

Is there an issue with using new? It is meant to be used as a class after all.

@MikeMcl
Copy link
Owner

MikeMcl commented Mar 7, 2020

There is problem creating instance of bignumber in typescript (probably also in JavaScript)

No, it's just in typescript.

This stackoverflow post seems to give some workarounds but I am not going to try and fix this issue myself.

I recommend that typescript users just use new.

Of course, if someone wants to amend the bignumber.d.ts file to fix this issue then a PR wpuld be welcome.

@MikeMcl MikeMcl closed this as completed Mar 7, 2020
@MikeMcl MikeMcl reopened this Mar 7, 2020
jbrower2 added a commit to jbrower2/bignumber.js that referenced this issue Dec 5, 2021
Add TypeScript binding to allow instantiating BigNumber without the `new` keyword
@MikeMcl MikeMcl closed this as completed in b951358 Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants