Angular - How to fix "ERROR TS2322: Type 'ModuleWithProviders<any>' is not assignable to type 'any[] | Type<any>'"

As i see, you have added Modules under declarations and components under imports, you should add Modules under imports and components under declarations.


  1. declarations is save components,pipes or directives.
  2. imports is save modules.
@NgModule({
  // right
  imports: [
    BrowserAnimationsModule,
    FormsModule,
    HttpClientModule,
    ComponentsModule,
    RouterModule,
    AppRoutingModule,
    NgbModule,
    ToastrModule.forRoot()
  ],
  // right
  declarations: [
    AppComponent,
    AdminLayoutComponent
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }