Home > database >  Angular - export ReactiveFormsModule.withConfig
Angular - export ReactiveFormsModule.withConfig

Time:12-28

I want to export the ReactiveFormsModule with the config in the SharedModule, but i have the below error

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 { }

CodePudding user response:

You can declare it with this typing:

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

Or simply:

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