2

One reason why I can't import i18next is because the i18next.d.ts file does not have

declare module "i18next" {
    export = i18next;
}

at the end, like jquery.d.ts and knockout.d.ts have. It only has

declare var i18next: I18nextStatic;

So when I tried to import in my TypeScript file using

import i18next = require('i18next'); 

it will barf: Cannot load external module Module cannot be aliased to a non-module type

I don't know why Definitely Typed project compose the d.ts file in that way. And I don't know if declare module will be a good solution or not.

Someone please help.

mehdi lotfi
  • 11,194
  • 18
  • 82
  • 128
yanglinfang1226
  • 151
  • 1
  • 5

1 Answers1

1

You probably need to Shim the i18next library so that RequireJS defines it as a module.

There's more info on the RequireJS site here: http://requirejs.org/docs/api.html#config-shim

shim : {
   'i18next' : {
      exports : 'i18next'
    }
}
Sam Tsai
  • 484
  • 4
  • 13
Jamie Dixon
  • 53,019
  • 19
  • 125
  • 162