Skip to content

Fix randomBytes import#160

Merged
christroutner merged 4 commits into
Bitcoin-com:stagefrom
jcramer:patch-2
Nov 21, 2019
Merged

Fix randomBytes import#160
christroutner merged 4 commits into
Bitcoin-com:stagefrom
jcramer:patch-2

Conversation

@jcramer
Copy link
Copy Markdown

@jcramer jcramer commented Nov 21, 2019

This patch fixes the issues I get when I run tsc in a brand new ts project (after running tsc --init) that depends on recent versions of bitbox-sdk:

node_modules/bitbox-sdk/lib/Crypto.ts:1:1
1 import * as randomBytes from "randombytes"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.

christroutner and others added 2 commits November 19, 2019 08:01
This patch fixes the issue I get when I run `tsc` in a ts project that depends on recent versions of bitbox-sdk:

  node_modules/bitbox-sdk/lib/Crypto.ts:1:1
    1 import * as randomBytes from "randombytes"
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    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.
@jcramer jcramer changed the base branch from master to stage November 21, 2019 15:14
The default typescript tsconfig.json file generated from `tsc --init` has this property set to true.  If there are no build errors or other failures resulting from this update, then it would probably be easier for other users to update this.
fix randomBytes import for same reason as Crypto.ts
@jcramer jcramer mentioned this pull request Nov 21, 2019
Copy link
Copy Markdown

@christroutner christroutner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran unit and integration tests against this branch. Everything passed.

@christroutner christroutner merged commit 7343fbe into Bitcoin-com:stage Nov 21, 2019
@cgcardona
Copy link
Copy Markdown

🎉 This PR is included in version 8.8.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@rvdende
Copy link
Copy Markdown

rvdende commented Jan 29, 2020

I'm getting this error with the latest bitbox-sdk.

node_modules/bitbox-sdk/lib/Crypto.ts:1:8 - error TS1259: Module '"/home/rouan/secretdevproject/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 '"/home/rouan/secretdevproject/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.

What's the best way to solve this? I already have esModuleInterop in my tsconfig.json

I'm using ubuntu WSL on win10, not sure if that matters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants