angular-tree-component:通用类型'ModuleWithProviders <T>'需要1个类型参数

问题描述

我使用的是angular v10和"angular-tree-component": "^8.5.6"。但出现构建错误

ERROR in node_modules/angular-tree-component/dist/angular-tree-component.d.ts:25:23 - error TS2314: Generic type 'ModuleWithProviders<T>' requires 1 type argument(s).

25     static forRoot(): ModuleWithProviders;

在这样的应用程序中使用

@NgModule({
  imports: [TreeModule],exports: [TreeModule]
   })

export class SharedModule { }

我需要做任何修改吗?

谢谢。

解决方法

代替新的“ angular-tree-component”,使用新的库“ @ circlon / angular-tree-component

npm uninstall angular-tree-component
npm i @circlon/angular-tree-component

,然后从以下位置更新项目中的所有导入:

import {TreeComponent} from 'angular-tree-component';

收件人:

import {TreeComponent} from '@circlon/angular-tree-component';

和CSS(如果需要):

@import '~angular-tree-component/dist/angular-tree-component.css';

@import "~@circlon/angular-tree-component/css/angular-tree-component.css";