问题描述
从Angular版本8升级到10后.
After upgrading from Angular version 8 to 10.
运行-ng serve命令会给我错误-
Running the - ng serve command gives me error -
node_modules/ngx-tree-select/src/module.d.ts.11:56中的错误-错误TS2314:通用类型'ModuleWithProviders'需要1个类型参数.
ERROR in node_modules/ngx-tree-select/src/module.d.ts:11:56 - error TS2314: Generic type 'ModuleWithProviders' requires 1 type argument(s).
11个静态的forRoot(选项:TreeSelectDefaultOptions):ModuleWithProviders;~~~~~~~~~~~~~~~~~~
11 static forRoot(options: TreeSelectDefaultOptions): ModuleWithProviders;~~~~~~~~~~~~~~~~~~~
这是我的文件-fronent/webapp/node_modules/ngx-tree-select/src/module.d.ts
This is my file - fronent/webapp/node_modules/ngx-tree-select/src/module.d.ts
import { ModuleWithProviders } from '@angular/core';
import { TreeSelectDefaultOptions } from './models/tree-select-default-options';
import * as ɵngcc0 from '@angular/core';
import * as ɵngcc1 from './components/tree-select.component';
import * as ɵngcc2 from './components/tree-select-item.component';
import * as ɵngcc3 from './directives/off-click.directive';
import * as ɵngcc4 from './pipes/item.pipe';
import * as ɵngcc5 from '@angular/common';
import * as ɵngcc6 from '@angular/forms';
export declare class NgxTreeSelectModule {
static forRoot(options: TreeSelectDefaultOptions): ModuleWithProviders;
static ɵmod: ɵngcc0.ɵɵNgModuleDefWithMeta<NgxTreeSelectModule, [typeof ɵngcc1.TreeSelectComponent, typeof ɵngcc2.TreeSelectItemComponent, typeof ɵngcc3.OffClickDirective, typeof ɵngcc4.ItemPipe], [typeof ɵngcc5.CommonModule, typeof ɵngcc6.FormsModule], [typeof ɵngcc1.TreeSelectComponent]>;
static ɵinj: ɵngcc0.ɵɵInjectorDef<NgxTreeSelectModule>;
}
//# sourceMappingURL=module.d.ts.map
推荐答案
要跳过此类型错误,只需在您的代码中添加:
To skip this type error just add in you code:
declare module "@angular/core" {
interface ModuleWithProviders<T = any> {
ngModule: Type<T>;
providers?: Provider[];
}
}
注意:这将修复类型检查并允许继续进行-如果您发现其他与Angular10不兼容的库-您需要请求库升级或找到另一个库.
Note: this will fix the type checking and allow to continue - if you will notice other lib to Angular10 inconmpatibilities - you need to ask lib upgrade or found another one.
这篇关于角度错误-通用类型'ModuleWithProviders< T>'需要1个类型参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!