You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Thank you for the PR. I'm not a user of Typescript, so I'm not really sure how to evaluate this. I'll try to see if any of the other committers for this repo have the prerequisite knowledge to evaluate this PR.
Thank you for bringing this to our attention. To get around this issue quickly I recommend adding "esModuleInterop": true to your TypeScript configuration file.
We will look into resolving all of the TS issues and improving the TS coverage of this library very soon.
Thanks for the feedback. I'm quite sure I tried with "esModuleInterop": true and still had the same problem, so I figured it is worth fixing in this package so others won't get the same issue.
Is there any blocker as why this hasn't been merged yet? esModuleInterop set to true breaks some other libraries and I'd like to avoid using it if possible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi
In a new typescript project when using bitbox-sdk by
npm i bitbox-sdk:When using tsc to compile the typescript it reports these errors:
I found that this works around the issue.