Ionic 2 RC0 And Angular 2 latest Error on Build android (ngc: Error: Error encountered resolving symbol values statically)

冷暖自知 提交于 2019-12-05 21:58:16

I found a workaround for that.

you don't have to export your dictionary object, just change the keys to static values.

This worked for me:

// all translations
const dictionary = {
  "en": LANG_EN_TRANS,
  "ar": LANG_AR_TRANS,
  "fr": LANG_FR_TRANS
};
// providers
export const TRANSLATION_PROVIDERS = [
  { provide: TRANSLATIONS, useValue: dictionary },
];

Yes exactly as said by @welefish in his answer, no need to export your dictionary object, you just have to change to keys to static value.

PS:- another method (Posting as answer because @welefish method is not working for me)

let en = LANG_EN_NAME;
let er = LANG_AR_NAME;
let fr = LANG_FR_NAME;

const dictionary : any = {
    en: LANG_EN_TRANS,
    er: LANG_AR_TRANS,
    fr: LANG_FR_TRANS
};

// providers
export const TRANSLATION_PROVIDERS = [
  { provide: TRANSLATIONS, useValue: dictionary },
];

Well, do what the compiler says :). Export your dictionary:

export const dictionary : any = {
    [LANG_EN_NAME]: LANG_EN_TRANS,
    [LANG_AR_NAME]: LANG_AR_TRANS,
    [LANG_FR_NAME]: LANG_FR_TRANS
};

Declare the type of [LANG_EN_NAME]:

export const LANG_EN_NAME : string = 'en';

Worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!