Skip to content
This repository was archived by the owner on Jun 17, 2021. It is now read-only.
This repository was archived by the owner on Jun 17, 2021. It is now read-only.

BN re-export failure #267

@martriay

Description

@martriay

Hello! I'm not being able to use the reexported version of BN.js from TypeScript due to how the export is defined. I'm using the 7.0.3 release.

Example code:

import { BN } from 'ethereumjs-util';

function hexStringIsZero(hexNumber: string): boolean {
  return new BN(hexNumber, 'hex').isZero();
}

Printed error plus suggested fix:

../core/src/Foo.ts:51:14 - error TS2351: This expression is not constructable.
  Type 'typeof BN' has no construct signatures.

51   return new BN(hexNumber, 'hex').isZero();
                ~~

  ../core/node_modules/ethereumjs-util/dist/externals.d.ts:6:1
    6 import * as BN from 'bn.js';
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions