Git Product home page Git Product logo

Comments (4)

jamuhl avatar jamuhl commented on June 3, 2024

https://github.com/i18next/i18next/blob/master/test/typescript/nonEsModuleInterop/exposed.test.ts
https://github.com/i18next/i18next/blob/master/test/typescript/init.test.ts

both work depending on ts config -> check above tests

from i18next-gitbook.

scharf avatar scharf commented on June 3, 2024

Thanks to a hint by @rosskevin I found a solution:

Adding the option "esModuleInterop": true to tsconfig.json the original (suggested) import works again:

import i18next from 'i18next' 

The point is, that something changed in i18ext that broke this import.

I had to add "esModuleInterop": true, otherwise I need a terrible hack to import i18next-xhr-backend

What confused me was that updating i18next form version 15.1.1 to 17.0.18 broke my code without me changing anything. That happened before, when I switched from 11.9.1 to 15.0.6 I had to change the import form

import * as i18next from 'i18next';

to

import i18next from 'i18next';

I have lots of dependencies but the i18n family of plugins now caused a few times headaches for me and therefore I reported the error (those are the only plugin that broke the imports after an update).

As I said, I did not know about the esModuleInterop option which seems to solve some problems.

I have to admit, I am still a bit confused how imports in typescript/javascript work and I have an an old unanswered question at stackoverflow: "When to use which import style for of CommonJs (node) modules in Typescript?"

from i18next-gitbook.

jamuhl avatar jamuhl commented on June 3, 2024

Fun fact for me...there is no issue (never ever) for users that use plain javascript es6 - but for typescript...there is a endless story of chaos (at least looks like this for me)...glad @rosskevin has the patience to go through this...so all kudos to him

from i18next-gitbook.

scharf avatar scharf commented on June 3, 2024

I agree, that javascript is more forgiving and using typescript is painful at times....

from i18next-gitbook.

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.