aurelia / i18n

A plugin that provides i18n support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error "Module 'aurelia-i18n' has no exported member 'configure'"

samueldjack opened this issue · comments

I'm submitting a bug report

  • Library Version:
    2.3.2

Please tell us about your environment:

  • Operating System:
    Windows 10

  • Node Version:
    v10.1.0

  • NPM Version:
    6.4
  • JSPM OR Webpack AND Version
    webpack 4.17
  • Browser:
    all

  • Language:
    TypeScript 3.0

Current behavior:
I'm attempting to register the aurelia-i18n plugin using the imported module method as enabled by the June release of Aurelia.

So I have this code

     import { configure as aureliai18n } from 'aurelia-i18n';
     ...
     aurelia.use
        .defaultBindingLanguage()
        .defaultResources()
        .eventAggregator()
        .plugin(aureliai18n);

I get an error on the first line shown above

     Module '"aurelia-i18n"' has no exported member 'configure'.

Expected/desired behavior:

  • What is the expected behavior?
    The configure function should be defined as an export in the typings file for aurelia-i18n

I really wonder why since it actually is exported https://github.com/aurelia/i18n/blob/master/src/aurelia-i18n.js#L87 and it's even used in some unit tests

I should clarify that this is a compile time error, not a run time error.

oh well ... I see the trouble. The dts-gen plugin simply creates stupid outputs for the generated typings. I guess you're using TypeScript which is why you hadn't seen this.

As a workaround for now, please try to do

import * as aureliaI18n from 'aurelia-i18n';

console.log((aureliaI18n as any).configure);

It's ugly as hell but I doubt anything I can do about it for now. I'm in the phase of rewriting the whole plugin to typescript and cleaning it up. So that will definitely be fixed with that next major release.

Sorry for the inconvenience so far

@samueldjack can you check with the latest beta release. The rewrite should now include proper types and should allow what you're planning to do here.

closing due to inactivity