imagekit-developer / imagekit-angular

Angular SDK for ImageKit.io client side file upload and URL generation
https://imagekit.io
18 stars 20 forks source link

Angular 16 - ModuleWithProviders indentical type error #78

Closed vdg437 closed 10 months ago

vdg437 commented 1 year ago

I updated to the most recent version of ImageKit (2.0.2) to get this library working with Angular 16. When building the app with "ng serve" I get following error:

Any idea how to make it work?

Node version : 18.10 Angular: 16.2.0 npm: 9.8.1

Error: node_modules/@angular/core/index.d.ts:5795:26 - error TS2428: All declarations of 'ModuleWithProviders' must have identical type parameters.

5795 export declare interface ModuleWithProviders<T> {
                              ~~~~~~~~~~~~~~~~~~~

Error: node_modules/imagekitio-angular/imagekitio-angular/imagekitio-angular.module.d.ts:4:15 - error TS2428: All declarations of 'ModuleWithProviders' must have identical type parameters.

4     interface ModuleWithProviders {
                ~~~~~~~~~~~~~~~~~~~

Error: node_modules/imagekitio-angular/imagekitio-angular/imagekitio-angular.module.d.ts:5:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'ngModule' must be of type 'Type<T>', but here has type 'Type<any>'.

5         ngModule: Type<any>;
          ~~~~~~~~

  node_modules/@angular/core/index.d.ts:5796:5
    5796     ngModule: Type<T>;
             ~~~~~~~~
    'ngModule' was also declared here.

Error: node_modules/imagekitio-angular/imagekitio-angular/imagekitio-angular.module.d.ts:6:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'providers' must be of type '(Provider | EnvironmentProviders)[]', but here has type 'Provider[]'.

6         providers?: (Provider)[] | undefined;
          ~~~~~~~~~

  node_modules/@angular/core/index.d.ts:5797:5
    5797     providers?: Array<Provider | EnvironmentProviders>;
             ~~~~~~~~~
    'providers' was also declared here.

Error: node_modules/imagekitio-angular/imagekitio-angular/imagekitio-angular.module.d.ts:10:52 - error NG6005: ImagekitioAngularModule.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.

10     static forRoot(config: ImageKitConfiguration): ModuleWithProviders;
MAkbarZ commented 1 year ago

1st - I have same error, I am still wondering what to do. 2nd - Please create a project for standalone components.

silviu4444 commented 12 months ago

Replace with this in node modules as it's stated in the header:

image

However, this should be updated in the official package because if you delete your node_modules or install the project in a production environment you won't get rid of the error!

Scryper commented 11 months ago

I have the same issue with angular 15.2.10 But @silviu4444 what if I want to deploy my app afterwards ? We can't make this change in the node_modules if we have (in my case) a GitHub action triggered to deploy the app

I think this should be fixed to have a production-ready solution

ankur-dwivedi commented 10 months ago

Utilizing version 3.0.0 of the imagekitio-angular package from https://www.npmjs.com/package/imagekitio-angular will address the problem.