' is not assignable to type ' any[] |类型<任何 >'"-6ren"> ' is not assignable to type ' any[] |类型<任何 >'"-我正在尝试使用 Angular 创建一个 webapp,但是在编译时我收到了这个我无法解决的错误: ERROR in src/app/app.module.ts(22,5): error TS2322-6ren">
gpt4 book ai didi

Angular - 如何修复 "ERROR TS2322: Type ' ModuleWithProviders' is not assignable to type ' any[] |类型<任何 >'"

转载 作者:行者123 更新时间:2023-12-03 09:47:38 26 4
gpt4 key购买 nike

我正在尝试使用 Angular 创建一个 webapp,但是在编译时我收到了这个我无法解决的错误:

ERROR in src/app/app.module.ts(22,5): error TS2322: Type 'ModuleWithProviders' is not assignable to type 'any[] | Type'. Type 'ModuleWithProviders' is missing the following properties from type 'Type': apply, call, bind, prototype, and 5 more.



那是我的 app.module.ts:
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { ToastrModule } from 'ngx-toastr';
import { AppRoutingModule } from './app-routing.module';
import { ComponentsModule } from './components/components.module';
import { AppComponent } from './app.component';
import { AdminLayoutComponent } from './layouts/admin-layout/admin-layout.component';

@NgModule({
declarations: [
BrowserAnimationsModule,
FormsModule,
HttpClientModule,
ComponentsModule,
RouterModule,
AppRoutingModule,
NgbModule,
ToastrModule.forRoot()
],
imports: [
AppComponent,
AdminLayoutComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

报错就行: ToastrModule.forRoot()

这就是我的 package.json:
{
"name": "pum-pum-pum",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "~7.3.7",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}

请有人帮助我。

最佳答案

如我所见,您已经在声明下添加了模块,在导入下添加了组件,您应该在导入下添加模块,在声明下添加组件。

关于Angular - 如何修复 "ERROR TS2322: Type ' ModuleWithProviders<any >' is not assignable to type ' any[] |类型<任何 >'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55742974/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com