Angular 错误 - 通用类型 'ModuleWithProviders<T>' 需要 1 个类型参数

标签 angular

从 Angular 版本 8 升级到 10 后。
运行 - ng serve 命令给我错误 -
node_modules/ngx-tree-select/src/module.d.ts:11:56 中的错误 - 错误 TS2314:通用类型“ModuleWithProviders”需要 1 个类型参数。
11 static forRoot(options: TreeSelectDefaultOptions): ModuleWithProviders;
~~~~~~~~~~~~~~~~~~~
这是我的文件 - front/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
请查看错误图像。
enter image description here

最佳答案

@user9882419 有我认为最好的方法。这是一个例子来说明他在说什么

export class AppSharedModule {
  static forRoot(): ModuleWithProviders<AppSharedModule> {
    return {
      ngModule: AppSharedModule
    };
  }
}

关于 Angular 错误 - 通用类型 'ModuleWithProviders<T>' 需要 1 个类型参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62755093/

相关文章:

Angular cli build prod : TypeError: Cannot read property 'kind' of undefined

angular - 蒙哥错误: user is not allowed to do action

angular - 在 Angular 2 中使用 Facebook SDK

javascript - 在表内加载另一个组件会意外地在Angular中扩展我的表宽度

c# - 如何使用后端 asp.net c# 的 Angular 网站读取其他网站数据

angular - 如何创建贴纸应用程序并将其发送到 WhatsApp 或任何使用 JS 框架(如 ionic 或 React Native)的信使?

angular - 如何在 ngx-leaflet 中放置热图?

angular - 导入的模块是否捆绑到 Angular 中的模块 block 文件中

html - 如何创建带虚线边框的圆形 svg 进度条

angular - 自动对焦只工作一次