我正在尝试在当前项目中启用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')
},
如果错误解决,它可能会成功构建
答案 0 :(得分:0)
将() => {}
替换为function() {}
会有所帮助。
答案 1 :(得分:0)
在声明模块之前尝试导出这样的函数
export function createCustomFormatter(): Function
{
return () => new CustomNgbDateParserFormatter('longDate');
}
然后在提供程序中使用该功能
providers: [
CommonService,
{
provide: NgbDateParserFormatter,
useFactory: createCustomFormatter
},