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

Child class extending BN, using BN in constructor

Open amaury1093 opened this issue 7 years ago • 1 comments

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

amaury1093 avatar Nov 13 '18 17:11 amaury1093

I think this is expected result, check constructor function: https://github.com/indutny/bn.js/blob/24cc2dd51b58694088a637a314689f61c9ba65a4/lib/bn.js#L22-L24

fanatid avatar Nov 13 '18 17:11 fanatid