库模块中的角度APP_INITIALIZER生成元数据编译时间错误

时间:2019-11-14 09:00:12

标签: angular angular-library angular-compiler

这是我的ng库模块代码

   @NgModule({
      imports: [NgIdleModule.forRoot()],
      providers: [ {
        provide: APP_INITIALIZER,
        useFactory: (idleStateChangeHandlerService: IdleStateChangeHandlerService) =>  () => console.log(IdleStateChangeHandlerService),
        multi: true,
        deps: [IdleStateChangeHandlerService]
      }]
    })
    export class IdleActivityModule {
      static forRoot(config: IdleActivityConfig): ModuleWithProviders {
        return {
          ngModule: IdleActivityModule,
          providers: [
            {
              provide: IdleActivityConfigInjectionToken,
              useValue: config
            }
          ]
        };
      }
    }

在构建中:

> Compiling TypeScript sources through ngc ERROR:
> C:/_dev/seemis-workspace/projects/shared-modules/src/lib/idle-activity/idle-activity.module.ts:9:1:
> Error encountered in metadata generated for exported symbol
> 'IdleActivityModule':  
> C:/_dev/seemis-workspace/projects/shared-modules/src/lib/idle-activity/idle-activity.module.ts:13:17:
> Metadata collected contains an error that will be reported at runtime:
> Lambda not supported.   {"__symbolic":"error","message":"Lambda not
> supported","line":12,"character":16}

如果我将APP_INITIALIZER提供程序移到应用程序模块中就可以了,但是我不希望应用程序具有此知识。

0 个答案:

没有答案