Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

595
Visualizações
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

over 4 years ago · Santiago Trujillo
11 Respostas
Responde à pergunta

0

The solve for the same error in my Angular 10.1.3 version, was change the param of export to .

With error:

export const appRoutingProviders: any[] = [];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);

After change:

export const appRoutingProviders: any[] = [];
export const routing: ModuleWithProviders<any> = RouterModule.forRoot(appRoutes);
over 4 years ago · Santiago Trujillo Relatório

0

One cause of this is upgrading Angular to a newer version (i.e. v10), yet having an older JS library that doesn't play nice and also needs to be updated. In my case I received the following error like the OP:

ERROR in [at-loader] ./node_modules/@ng-bootstrap/ng-bootstrap/popover/popover.module.d.ts:6:23 TS2314: Generic type 'ModuleWithProviders' requires 1 type argument(s).

Notice in my instance the particular offending library was called out which was @ng-bootstrap It indeed was on a much older version:

"@ng-bootstrap/ng-bootstrap": "^2.0.0"

I was able to update the package to version 7.0.0 and the error went away and the application built successfully. The main solution here is don't immediately throw in the fixes recommended here or use <any> in place of a type. There might just be another package you need to update to bring you app compliant with the version of Angular being used to fix the issue correctly.

over 4 years ago · Santiago Trujillo Relatório

0

@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
    };
  }
}
over 4 years ago · Santiago Trujillo Relatório

0

To skip this type error just add in you code:

declare module "@angular/core" {
    interface ModuleWithProviders<T = any> {
        ngModule: Type<T>;
        providers?: Provider[];
    }
}

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.

over 4 years ago · Santiago Trujillo Relatório

0

You just need to specify the type (the name of the module class) between ModuleWithProviders

over 4 years ago · Santiago Trujillo Relatório

0

It seems this ngx-tree-select library has not evolved with latest Angular versions. Maybe you should open a PR request or an issue on the repo.

over 4 years ago · Santiago Trujillo Relatório

0

since you got error in node modules you have limited scope to fix. So please try to get the latest compatible version with the angular(your version).

over 4 years ago · Santiago Trujillo Relatório

0

Just provide "unknown" as Type-Argument. I had the same issue and I solved it as in the following snippet

export const routingModule: ModuleWithProviders<unknown> = RouterModule.forRoot(
  routes
);
over 4 years ago · Santiago Trujillo Relatório

0

add this code in your tsconfig.app.json "skipLibCheck": true,

enter image description here

over 4 years ago · Santiago Trujillo Relatório

0

I had a bunch of errors. I had to go through them one by one and update the packages to later versions where the publishers had already fixed this. Look at the file name and it'll give you a clue what package needs to be updated. At least one of the packages didn't have a current update and had a massive backlog of issues and pull requests. I don't know what I'm going to do about that one. I might either have to replace that package with something else or use one of the solutions here.

over 4 years ago · Santiago Trujillo Relatório

0

If you are facing issues in toastr.module.ts

Before:-

export declare class ToastrModule {
    static forRoot(config?: Partial<GlobalConfig>): ModuleWithProviders;
}
export declare class ToastrComponentlessModule {
    static forRoot(config?: Partial<GlobalConfig>): ModuleWithProviders;
}

After:-

export declare class ToastrModule {
    static forRoot(config?: Partial<GlobalConfig>): ModuleWithProviders<any>;
}
export declare class ToastrComponentlessModule {
    static forRoot(config?: Partial<GlobalConfig>): ModuleWithProviders<any>;
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda