Closed scharf closed 4 years ago
The only way I could get it to work is
// @ts-ignore
import XHR = require('i18next-xhr-backend/dist/cjs/i18nextXHRBackend.js');
@rosskevin sorry, to having bother you with all the typescript issues...but can't make any sense out of this...
Our ts usage test (not runtime test) proves a typical default import works: https://github.com/i18next/i18next-xhr-backend/blob/master/test/typescript/i18next-xhr-backend.ts#L1
The runtime code also shows a default export.
If you are having to do something different with imports, I assume you are doing something to cause this with your tsconfig. Checking the one here, we are not turning on synthetic or esModuleInterop, so it would seem nothing special is needed and I don't know how to guide you here.
BTW, if you are new and just getting started:
allowSyntheticDefaults: true esModuleInterop: true
Is going to save you headaches with imports.
I did not know about those options. I added the option to my project (which broke a few other imports that I fixed) and now it words.
But there seems no way to use XHR
in TypeScript unless you set "esModuleInterop": true
in tsconfig.json
, or am I missing something here?
That should not be true, but you can definitely misconfigure tsconfig to make it incompatible.
but you can definitely misconfigure tsconfig to make it incompatible.
using the defaults is misconfiguring?
No, defaults should work fine - as they are tested here - they work. See the tsconfig in this repo, but you can change module, target, typeroots, includes, etc in incompatible ways.
I migrated form
2.0.1
to3.2.0
. With2.0.1
the import code (from TypeScript on the client) looked like:After updating to
3.2.0
the value ofXHR
is nowundefined
.This import does not work either:
And the following import throws an error.
So, I am pretty clueless, how to import the module...