angular-gtag icon indicating copy to clipboard operation
angular-gtag copied to clipboard

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

Open ratkorle opened this issue 5 years ago • 8 comments

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;

ratkorle avatar Oct 29 '20 12:10 ratkorle

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.

IamSumitJangid avatar May 27 '21 12:05 IamSumitJangid

The same with Angular 16.

yorikworld avatar Sep 03 '23 18:09 yorikworld

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 ?

iamnaveenoff avatar Nov 23 '23 07:11 iamnaveenoff