GithubHelp home page GithubHelp logo

Comments (4)

apucacao avatar apucacao commented on June 14, 2024

Hi @germs12 , sorry about that. We're looking into it. I think it is related to our recent switch to rollup.js.

from js-client-sdk.

germs12 avatar germs12 commented on June 14, 2024

@apucacao Thank you for the prompt response. Let me know if you'd like me to test anything. In the mean time I'll rock the LDClient.default.initalize(...) 🕺

from js-client-sdk.

apucacao avatar apucacao commented on June 14, 2024

It looks like there's something going on with the default export in TypeScript specifically.

We emit ES modules (along with CommonJS and UMD modules). ./dist/ldclient.es.js does have a default export, meaning that the import in TS should just be import LDClient from 'ldclient-js'.

However, we used to do this: module.exports = { initialize, version };. From what I understand, that equates to the export default { initialize, version };, but evidently, TS doesn't think so.

I found that TS has this option available for making this work properly, in your tsconfig.json:

"allowSyntheticDefaultImports": true,

Does that allow you to avoid LDClient.default.initialize? I tried in one of our TS projects and it helped, but let me know if it works for you. 🙂

from js-client-sdk.

germs12 avatar germs12 commented on June 14, 2024

@apucacao Thank you again for the prompt and detailed response. I have tried out your suggestions and I have the following notes to report back.

  1. It works. 🍰
  2. If I change my import from import * as LDClient from 'ldclient-js' to import LDClient from 'ldclient-js', it compiles correctly but I get a TypeScript error in my editor (VSCode) saying Module ''ldclient-js'' has no default export.
  3. If I only update my tsconfig.json and leave my import as import * as LDClient from 'ldclient-js' I still need to call default to make it work.

🌵

from js-client-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.