在更新到最新版本的angular cli之后,我会遇到类似于下面的错误

ERROR in Error遇到静态解析符号值 . 不支持函数调用 . 考虑使用对导出函数的引用替换函数或lambda(原始.ts文件中的位置19:46),解析/src/app/custom-error-handler.ts中的符号CUSTOM_ERROR_PROVIDER,解析src / app中的符号AppModule /app.module.ts,解析src / app / app.module.ts中的符号AppModule

以下是我的自定义错误提供程序

export var CUSTOM_ERROR_PROVIDER = [{provide:ErrorHandler,useFactory:(appInsightsService:AppInsightsService)=> new CustomErrorHandler(appInsightsService),deps:[AppInsightsService]}];

我理解这些是因为编译而导致的错误 . 当我尝试使用“ng serve”命令在本地运行项目时,我没有使用--aot switch . 如果我不关心编译,我该如何解决这些错误?另外,如果我想让我的代码兼容,那么编写代码的更好方法是什么?

Update

将CUSTOM_ERROR_PROVIDER更改为纯函数后,我收到另一个错误 .

ERROR in Error遇到静态解析符号值 . 不支持表达式表单(原始.ts文件中的位置8:5),在/app/main/home/home.routing.ts中解析符号homeRoutes,解析src / app / main / main.routing.ts中的符号MainRoutingModule,在src / app / main / main.routing.ts中解析符号MainRoutingModule,解析mbe50web / src / app / main / main.routing.ts中的符号MainRoutingModule

以下是它抱怨的主路线常数

export const homeRoutes:Routes = [{path:'home',component:HomeComponent,} as Route,];