Angular - 导出 ReactiveFormsModule.withConfig

Angular - export ReactiveFormsModule.withConfig

我想用 SharedModule 中的配置导出 ReactiveFormsModule,但出现以下错误

Type 'ModuleWithProviders < ReactiveFormsModule > ' is missing the following properties from type 'Type': apply, call, bind, prototype, and 5 more.

@NgModule({
  imports: [
    ReactiveFormsModule.withConfig({ warnOnNgModelWithFormControl: 'never' })
  ],
  declarations: [ ],
  exports: [
    ReactiveFormsModule.withConfig({ warnOnNgModelWithFormControl: 'never' }) // error in this line
 ],
  entryComponents: [ ]
})
export class SharedModule { }

您可以使用以下类型声明它:

exports: [
    ReactiveFormsModule.withConfig({ warnOnNgModelWithFormControl: 'never' }) as unknown as Type<ModuleWithProviders<ReactiveFormsModule>>
 ],

或者简单地说:

exports: [
    ReactiveFormsModule.withConfig({ warnOnNgModelWithFormControl: 'never' }) as any
 ],