Typescript 2.1.5不支持函数调用 [英] Typescript 2.1.5 Function calls are not supported

查看:76
本文介绍了Typescript 2.1.5不支持函数调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下ngrx减速器功能

I have the following ngrx reducer function

export const raceReducer: ActionReducer<IRace> = ( state: IRace = new Race(), action?: Action ) => {
  switch ( action.type ) {

    case RaceActions.ADD_OLP:
      return ngrxStateUpdater( state, action )

    default:
      return state;
  }
};

运行该应用程序会出现以下错误:

Running the application gives the following error:

ERROR in Error遇到静态解析符号值的情况.不支持函数调用.考虑更换功能或引用导出函数的lambda(位置40:50)原始.ts文件),在J:/wor中解析符号raceReducerkspace/angular2/ts/epimss/src/app/registration/race/race.ngrx-store.ts,在其中解析符号AppModuleJ:/workspace/angular2/ts/epimss/src/app/app.module.ts,解析符号AppModule中J:/workspace/angular2/ts/epimss/src/app/app.module.ts,解析输入符号Ap pModuleJ:/workspace/angular2/ts/epimss/src/app/app.module.ts

ERROR in Error encountered resolving symbol values statically. Function calls are not s upported. Consider replacing the function or lambda with a reference to an exported fun ction (position 40:50 in the original .ts file), resolving symbol raceReducer in J:/wor kspace/angular2/ts/epimss/src/app/registration/race/race.ngrx-store.ts, resolving symbo l AppModule in J:/workspace/angular2/ts/epimss/src/app/app.module.ts, resolving symbol AppModule in J:/workspace/angular2/ts/epimss/src/app/app.module.ts, resolving symbol Ap pModule in J:/workspace/angular2/ts/epimss/src/app/app.module.ts

所指功能是

( state: IRace = new Race(), action?: Action )

这是为什么,什么是解决方案.我认为这应该是合法的typescript2.1.5代码,但事实并非如此.

Why is this and what is the solution. I thinks this should be legitimate typescript2.1.5 code, but it does not seem that way.

谢谢

推荐答案

AoT需要静态分析某些代码,而不能分析函数调用.

AoT needs to statically analyze some code and can't analyze function invocations.

有关AoT限制的更多详细信息,请参见 https://github.com/qdouble/angular-webpack2-starter#aot--donts

For more details about the limitations of AoT see https://github.com/qdouble/angular-webpack2-starter#aot--donts

有关讨论,请参见此问题 https://github.com/angular/angular/issues/11262

For a discussion see this issue https://github.com/angular/angular/issues/11262

这篇关于Typescript 2.1.5不支持函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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