bn.js
bn.js copied to clipboard
Child class extending BN, using BN in constructor
import BN from "bn.js";
class MyBN extends BN {
doSomething() {
console.log("HELLO");
}
}
const a = new MyBN(new BN(123));
console.log(a.toString()); // this works, logs 123
a.doSomething();
Expected: Logs HELLO
Actual:
Doesn't log anything on the doSomething line.
Repro: https://codesandbox.io/s/508mm5zz5l
Notes: Using typescript 3.0.1
I think this is expected result, check constructor function: https://github.com/indutny/bn.js/blob/24cc2dd51b58694088a637a314689f61c9ba65a4/lib/bn.js#L22-L24