静态解析符号值时遇到错误.不支持函数调用.考虑更换函数或lambda吗? [英] Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda?

查看:68
本文介绍了静态解析符号值时遇到错误.不支持函数调用.考虑更换函数或lambda吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试启动npm时出现错误:

I get an error when try to start 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

with a reference to an exported function (position 47:19 in the original .ts file), resolving symbol CoreModule in D:/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
  ]

所以,它曾经工作过.

推荐答案

您需要提取箭头函数,如:

You need to extract your arrow function like:

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
  ]

另请参见

这篇关于静态解析符号值时遇到错误.不支持函数调用.考虑更换函数或lambda吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆