Search code examples
angulartypescript2.1

Typescript 2.1.5 Function calls are not supported


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 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

The function referred to is the

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

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.

Thanks


Solution

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

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

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