-
Notifications
You must be signed in to change notification settings - Fork 757
Open
Description
Hi,
Thanks for this great library.
I'm developing a subclass by extending BigNumber to add my custom utility methods. However, when I tried to access superclass methods, I got type errors from TypeScript. (The code works as expected; I just got TypeScript typing errors).
class ExtendedNumber extends BigNumber {
foo(): number {
return 1000;
}
bar(x: number): this {
const c = this.plus(x);
const d = c.foo(); // <--------------- ERROR: Property 'foo' does not exist on type 'BigNumber'. ts(2339)
return this;
}
}
const value = new ExtendedNumber("10.1");
console.log(value.foo());
console.log(value.bar(1));The problem is that the return type of methods is hard-coded as BigNumber. They should be this instead of BigNumber.
For example see the original code from bignumber.d.ts file below:
plus(n: BigNumber.Value, base?: number): BigNumber;It should be:
plus(n: BigNumber.Value, base?: number): this;Kind Regards,
Metadata
Metadata
Assignees
Labels
No labels