3

I get "Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol DeclarantModule" error when trying to compile my app. This happens when a module has forRoot or StoreModule.provideStore(rootReducer) function calls.

How to fix it? Why is this happens? I don't understand it I thought it is native angular 2 functions that import modules with configs.

Lyubimov Roman
  • 1,269
  • 15
  • 27
  • For now, it seems like you can't configure modules and use AOT both. – lexigren Dec 29 '16 at 06:46
  • Try reverting to angular version 2.3.1 as described here: http://stackoverflow.com/questions/41463860/how-to-use-routermodule-forroot-in-angular2-compiler-cli-ngc-command/41480174#41480174 – Piet K Jan 05 '17 at 08:40

1 Answers1

0

I received this error providing angular's 'LOCALE_ID' based on this post https://stackoverflow.com/a/39344889/4956569

Solved as the error message suggest... exporting it as a function...

post's original implementation (not working with AOT compilation)

{
  provide: LOCALE_ID,
  deps: [SettingsService],      //some service handling global settings
  useFactory: (settingsService) => settingsService.getLanguage()  //returns locale string
}

my fixed implementation (working with AOT compilation)

{
  provide: LOCALE_ID,
  deps: [SettingsService],      //some service handling global settings
  useFactory: localeIdFactory
}
export function localeIdFactory(settingsService: SettingsService) {
  return settings.getLanguage();
}
Luca Ritossa
  • 1,118
  • 11
  • 22