2

I just migrated my project under angular-cli and I'm getting this error when I start it:

ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 63:45 in the original .ts file), resolving symbol AppModule in C:/Data/Private/Innovation/EV/ev-dashboard/src/app/app.module.ts

Which corresponds to the APP_INITIALIZER below in app.module.ts:

...
providers: [ // expose our Services and Providers into Angular's dependency injection
    APP_PROVIDERS,
    ConfigService,
    { provide: APP_INITIALIZER, useFactory: (config: ConfigService) => () => config.load(), deps: [ConfigService], multi: true }
...

What is funny is that when I comment this line, it starts well and uncomment it afterward which triggers a compilation without error this time!!!

Do you have an idea?

Thanks, Serge.

1 Answer 1

1

You need to extract function like:

export function configFactory(config: ConfigService) {
  return () => config.load()
}

...
providers: [{ 
  provide: APP_INITIALIZER, 
  useFactory: configFactory, 
  deps: [ConfigService], 
  multi: true 
}

See also

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.