【问题标题】:Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda?静态解析符号值时遇到错误。不支持函数调用。考虑替换函数或 lambda?
【发布时间】:2017-09-21 14:23:38
【问题描述】:

尝试启动 npm 时出现错误:

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

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

核心是:

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

所以,它以前工作过。

【问题讨论】:

    标签: angular


    【解决方案1】:

    您需要像这样提取箭头函数:

    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
      ]
    

    另见

    【讨论】:

    • 谢谢!你是英雄!
    猜你喜欢
    • 2017-07-06
    • 1970-01-01
    • 2017-06-07
    • 2017-06-10
    • 2017-07-28
    • 2018-03-04
    • 2017-12-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多