Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

randombytes esModuleInterop import flag error #174

Open
rvdende opened this issue Feb 4, 2020 · 1 comment
Open

randombytes esModuleInterop import flag error #174

rvdende opened this issue Feb 4, 2020 · 1 comment
Labels
Typescript Requires expertise in TypeScript

Comments

@rvdende
Copy link

rvdende commented Feb 4, 2020

Hi

In a new typescript project when using bitbox-sdk by npm i bitbox-sdk:

import { BITBOX } from 'bitbox-sdk'
let bitbox = new BITBOX();
bitbox.Mnemonic.generate()

When using tsc to compile the typescript it reports these errors:

C:\Users\rouan\Desktop\work\tempbitbox>tsc test.ts
node_modules/bitbox-sdk/lib/Crypto.ts:1:8 - error TS1259: Module '"C:/Users/rouan/Desktop/work/tempbitbox/node_modules/@types/randombytes/index"' can only be default-imported using the 'esModuleInterop' flag

1 import randomBytes from "randombytes"
         ~~~~~~~~~~~

  node_modules/@types/randombytes/index.d.ts:10:1
    10 export = randomBytes;
       ~~~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/bitbox-sdk/lib/Mnemonic.ts:5:8 - error TS1259: Module '"C:/Users/rouan/Desktop/work/tempbitbox/node_modules/@types/randombytes/index"' can only be default-imported using the 'esModuleInterop' flag

5 import randomBytes from "randombytes"
         ~~~~~~~~~~~

  node_modules/@types/randombytes/index.d.ts:10:1
    10 export = randomBytes;
       ~~~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.


Found 2 errors.

This leads me to believe that we need to change code in bitbox-sdk or the randombytes module? Anyone that can provide input on this?

@rvdende
Copy link
Author

rvdende commented Feb 4, 2020

I've created a PR that solves this issue: #175

All npm run test passes all 2242 tests.

@christroutner christroutner added the Typescript Requires expertise in TypeScript label Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typescript Requires expertise in TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants