5不支持函数调用

5不支持函数调用

本文介绍了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:

所指功能是

( 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不支持函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 02:10