角度错误-通用类型'ModuleWithProviders< T>'需要1个类型参数 [英] Angular error - Generic type 'ModuleWithProviders<T>' requires 1 type argument(s)

查看:1273
本文介绍了角度错误-通用类型'ModuleWithProviders< T>'需要1个类型参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从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&lt; T&gt;'需要1个类型参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆