1

我正在尝试在我当前的项目中启用 angularivy,而 ng build 我得到了这个错误。

ERROR in src\app\app.module.ts(172,19): Error during template compile of 'AppModule'
  Function expressions are not supported in decorators
    Consider changing the function expression into an exported function.
src/app/home/home.component.ts(95,4): error TS2554: Expected 2 arguments, but got 1.
src/app/home/home.component.ts(96,4): error TS2554: Expected 2 arguments, but got 1.
node_modules/ngx-bootstrap/timepicker/models/index.d.ts(3,22): error TS2307: Cannot find module '@angular/core/src/type'.
src/app/nomina/solicitudes/vacaciones/vacaciones.component.ts(56,4): error TS2554: Expected 2 arguments, but got 1.

我已经检查了一些建议,例如在导出中创建函数并再次使用它,但错误发生了变化而不是被解决。

  ],
  exports: [],
  entryComponents: [],
  providers: [
    AuthGuard, 
    { provide: LOCALE_ID, useValue: 'es' },
    CommonService, 
    {
      provide: NgbDateParserFormatter,
      useFactory: () => new CustomNgbDateParserFormatter('longDate')
    },

如果错误解决,它可能会成功构建

4

2 回答 2

0

替换() => {}function() {}有所帮助。

于 2019-07-19T06:54:23.290 回答
0

在声明模块之前尝试像这样导出函数

export function createCustomFormatter(): Function
{
  return () => new CustomNgbDateParserFormatter('longDate');
}

然后在提供程序中使用该功能

providers: [
  CommonService, 
  {
    provide: NgbDateParserFormatter,
    useFactory: createCustomFormatter
  },
于 2019-07-19T08:30:51.657 回答