问题
After installed angular-autofocus-fix
imported the AutofocusModule
When i run the angular projects its shows below error:
ERROR in node_modules/angular-autofocus-fix/index.d.ts:4:23 - error TS2314: Generic type 'ModuleWithProviders<T>' requires 1 type argument(s).
static forRoot(): ModuleWithProviders
When i check in that node_mudule
I am using angular 10 in my project.
回答1:
it seems it is not updated for Angular 10, ModuleWithProviders can no longer be used witthout generic (https://angular.io/guide/updating-to-version-10#new-removals-of-deprecated-apis)
there is an issue on the repo about it: https://github.com/korniychuk/angular-autofocus-fix/issues/14
回答2:
By adding this below given code snippet in app.module.ts
fixed the issue
declare module "@angular/core" {
interface ModuleWithProviders<T = any> {
ngModule: Type<T>;
providers?: Provider[];
}
}
In my case, this problem happened when I upgraded ng-bootstrap
version in angular-10
.
来源:https://stackoverflow.com/questions/63078349/modulewithproviderst-requires-1-type-arguments-angular-autofocus-fix