gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 10:15:03 32 4
gpt4 key购买 nike

从 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/

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