Alessandro Celeghin
Alessandro Celeghin

Reputation: 4199

Error resolving symbol values statically- Angular 4

Hi I have extended http and this is my module:

providers: [
    {
      provide: HttpService,
      useFactory: (backend: XHRBackend, options: RequestOptions) => {
        return new HttpService(backend, options);
      },
      deps: [XHRBackend, RequestOptions]

The first 'ng serve' give me this error:

Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda w ith a reference to an exported function

But compilation is successful after I just press Ctrl + S to a file again without changing anything. What I have to change in my module to solve this "casual" error?

Upvotes: 1

Views: 124

Answers (1)

khollenbeck
khollenbeck

Reputation: 16157

This is the AOT compiler complaining about the Arrow Function (lambda). () => {}. Try changing this.

useFactory: (backend: XHRBackend, options: RequestOptions) => {
    return new HttpService(backend, options);
},

To this:

deps: [XHRBackend, RequestOptions],
useFactory(backend: XHRBackend, options: RequestOptions) {
   return new HttpService(backend, options);
},

Here is a helpful article about this. https://medium.com/@isaacplmann/making-your-angular-2-library-statically-analyzable-for-aot-e1c6f3ebedd5

Related:

https://github.com/angular/angular/issues/13614

Upvotes: 2

Related Questions