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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy