在静态解析符号值时遇到错误。不支持函数调用。考虑更换函数或lambda?

时间:2017-09-21 14:23:38

标签: angular

尝试启动npm时出错:

Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda 

引用导出的函数(位置47:19 在原始.ts文件中),解析符号 D中的CoreModule:/Projects/UI3/src/app/core/core.module.ts

核心是:

providers: [
    {provide: HttpService,
      useFactory: (backend: XHRBackend, options: RequestOptions) => { // Here 47 line number
        return new HttpService(backend, options);
      },
      deps: [XHRBackend, RequestOptions]},
    AuthenticationService,
    DialogsService,
    AuthenticationGuard,
    I18nService
  ]

所以,它以前有用过。

1 个答案:

答案 0 :(得分:4)

您需要提取箭头功能,如:

export function httpServiceFactory(backend: XHRBackend, options: RequestOptions) { 
    return new HttpService(backend, options);
}

...

@NgModule({
  ...
  providers: [
    {
        provide: HttpService,
        useFactory: httpServiceFactory,
        deps: [XHRBackend, RequestOptions]
    },
    AuthenticationService,
    DialogsService,
    AuthenticationGuard,
    I18nService
  ]

另见