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.
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'
}
}
来源:https://stackoverflow.com/questions/25134054/cannot-load-external-module-when-trying-to-import-i18next-in-typescript