Closed rmja closed 5 years ago
Hi @rmja.
We sadly can't add this import. We had it before but it behaves super strange with JS consumers. The trouble comes from the default export being used by the backing library i18next. So as said as it is we really can't do too much about this one.
Ahh crap. Would it then be possible to rewrite the .d.ts in the dist folder (https://github.com/aurelia/i18n/blob/master/dist/aurelia-i18n.d.ts#L1) in the build script. I guess this file is only consumed by Typescript users.
Not sure if that alone really helps. Could you give it a try locally and see whether thats enough? Weve got even a build step in place which just modifies the d.ts the other way around
It seems to work.
If I have:
.plugin(PLATFORM.moduleName("aurelia-i18n"), (instance: I18N) => {
instance.i18next.use(Backend); // <-- Typescript compile error here
return instance.setup({
backend: {
loadPath: 'locales/{{lng}}/{{ns}}.json'
},
lng: 'da'
});
})
Then I get a Typescript compile error on the marked line. The compile error goes away if I manually set import * as i18next from 'i18next';
in node_modules/aurelia-i18n/dist/aurelia-i18n.d.ts
in my project.
btw. what version of i18next was installed for you @rmja. It might be that the typings issue got fixed with one of their latest releases. There is another currently active PR for I18N which addresses the update from v 11 to 14 so maybe in between there is a change affecting your's as well.
Anyways can I ask you to modify your PR to revert the change for i18n.ts and instead modify this section here, which is responsible for the d.ts generation.
Closing in favor of https://github.com/aurelia/i18n/pull/299
The current import syntax produces a .d.ts file that requires the consuming app to compile with
allowSyntheticDefaultImports: true
.