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

@types/urijs/index can only be default-imported using the 'allowSyntheticDefaultImports' flag #414

Open
BenRacicot opened this issue May 26, 2022 · 1 comment

Comments

@BenRacicot
Copy link

Hello, I found an error that seems to be related to URIjs and ES6. Someone from 2016 [288] seems to have found this previously and couldnt replicate but here are the steps. Could you help me understand how to get around this?

Error: node_modules/stellar-sdk/lib/server.d.ts:2:8 - error TS1259: Module '"/node_modules/@types/urijs/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag

2 import URI from "urijs";
         ~~~

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

To replicate

  1. ng new AppName
  2. npm install --save stellar-sdk
  3. add the SDK to the app within angular.json's build scripts: ["./node_modules/stellar-sdk/dist/stellar-sdk.min.js"]
  4. run the app to see the error
@BenRacicot
Copy link
Author

BenRacicot commented May 26, 2022

Figured this out quickly and thought I'd leave the fix here.

The usage stated an import like

import * as StellarSDK from "stellar-sdk";

that's where allowSyntheticDefaultImports comes in. From TS docs.

Allow Synthetic Default Imports -
allowSyntheticDefaultImports
When set to true, allowSyntheticDefaultImports allows you to write an import like:

import React from "react";
instead of:

import * as React from "react";

Please feel free to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant