angular-gtag
angular-gtag copied to clipboard
Generic type 'ModuleWithProviders<T>' requires 1 type argument(s)
I have followed the set up instructions on: https://www.npmjs.com/package/angular-gtag
npm i angular-gtag
in app.module.ts:
GtagModule.forRoot({ trackingId: environment.GOOGLE_TAG_ID, trackPageviews: true }),
Angular version: 10.1.1
On ng serve I am getting this error:
ERROR in node_modules/angular-gtag/src/gtag.module.d.ts:4:41 - error TS2314: Generic type 'ModuleWithProviders<T>' requires 1 type argument(s).
4 static forRoot(config: GtagConfig): ModuleWithProviders;
Hello
To fix the error you need to edit this file in node_modules
gtag.module.d.ts.__ivy_ngcc_bak
you need to add the type **<GtagModule>** with the ModuleWithProviders
static forRoot(config: GtagConfig): ModuleWithProviders;
the output will look like this.
static forRoot(config: GtagConfig): ModuleWithProviders<GtagModule>;
then try **ng server**
it fixed for me.
The same with Angular 16.
after updating my project to angular 16
am facing this issue
Error: node_modules/angular-gtag/src/gtag.module.d.ts:4:41 - error NG6005: GtagModule.forRoot returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.
4 static forRoot(config: GtagConfig): ModuleWithProviders;
how to fix this is this compatible with angular 16 ?