royNiladri / js-big-decimal

Work with large numbers on the client side with high precision.
https://www.npmjs.com/package/js-big-decimal
MIT License
147 stars 28 forks source link

Allow extension methods #67

Open robstoll opened 2 years ago

robstoll commented 2 years ago

Describe the bug I would like to create an extension method

To Reproduce

declare module 'js-big-decimal' {
}

Fails with "is a non-module entity"

Expected behavior A clear and concise description of what you expected to happen.

Additional context Add any other context about the problem here.

royNiladri commented 1 year ago

Hi, You can extend the class as follows:

import bigDecimal from "js-big-decimal";

class bigger extends bigDecimal {
  sayHi(text: string) {
    console.log("Say hi ", text);
  }
}

const b = new bigger("232.54");
console.log(b.getPrettyValue());
console.log(b.sayHi("Nil"));

Which can be run normally:

image