Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
595 views
in Technique[技术] by (71.8m points)

Angular error - Generic type 'ModuleWithProviders<T>' requires 1 type argument(s)

After upgrading from Angular version 8 to 10.

Running the - ng serve command gives me error -

ERROR in node_modules/ngx-tree-select/src/module.d.ts:11:56 - error TS2314: Generic type 'ModuleWithProviders' requires 1 type argument(s).

11 static forRoot(options: TreeSelectDefaultOptions): ModuleWithProviders; ~~~~~~~~~~~~~~~~~~~

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

Kindly view the image for the error.

enter image description here

question from:https://stackoverflow.com/questions/62755093/angular-error-generic-type-modulewithproviderst-requires-1-type-arguments

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

@user9882419 has the best approach i believe. Here is an example to illustrate what he is saying

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...