rxfire icon indicating copy to clipboard operation
rxfire copied to clipboard

"Generic type 'AggregateQuerySnapshot<T>' requires 1 type argument(s)."

Open tdkehoe opened this issue 1 year ago • 10 comments

My Angular app won't compile with rxfire 6.0.5. The error is

Error: node_modules/rxfire/firestore/lite/interfaces.d.ts:8:29 - error TS2314: Generic type 'AggregateQuerySnapshot<T>' requires 1 type argument(s).

 8 export type CountSnapshot = lite.AggregateQuerySnapshot<{
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 9     count: lite.AggregateField<number>;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 }, any, DocumentData>;
   ~~~~~~~~~~~~~~~~~~~~~

This is with Firebase 9.23.0. I can't get Firebase 10 to work, see my StackOverflow question.

tdkehoe avatar Sep 01 '23 19:09 tdkehoe

Why is rxfire trying to use Firestore Lite? I never imported anything from firebase/firestore/lite.

tdkehoe avatar Sep 01 '23 20:09 tdkehoe

Same issue, I temporarily fixed it by forcing it to 6.0.4.

msapcili avatar Sep 01 '23 20:09 msapcili

Same issue here while using @angular/fire - fixed by installing rxfire 6.0.4 too.

igoraugustynski avatar Sep 04 '23 18:09 igoraugustynski

Same issue here with @angular/fire but in my case installing rxfire 6.0.4 didn't help. I tried to install 6.0.3 because this was my previous version in package-lock but it didn't help too so I had to restore my whole previous package-lock where I use rxfire 6.0.3, so probably some other package makes issue too

hvma411 avatar Sep 09 '23 15:09 hvma411

I think the issue here is that [email protected] introduced a breaking change and now requires firebase@10 to function. So sticking to [email protected] with firebase@9 is the solution.

Adding this override to package.json resolves the issue for me:

{
  "dependencies": {
    "@angular/fire": "~7.6.1"
  }
  "overrides": {
    "@angular/fire@~7.6.1": {
      "rxfire@^6.0.0": "6.0.3"
    }
  }
}

rgant avatar Sep 12 '23 14:09 rgant

I think the issue here is that [email protected] introduced a breaking change and now requires firebase@10 to function. So sticking to [email protected] with firebase@9 is the solution.

Adding this override to package.json resolves the issue for me:

{
  "dependencies": {
    "@angular/fire": "~7.6.1"
  }
  "overrides": {
    "@angular/fire@~7.6.1": {
      "rxfire@^6.0.0": "6.0.3"
    }
  }
}

I had commented about my temporary fix by forcing my app to use 6.0.4 but this is more reliable solution.

I was getting unexpected firebase integration errors such as "FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call initializeApp() first (app/no-app)". Then I tried to force 6.0.3 and these errors are also solved.

Thanks rgant.

msapcili avatar Sep 25 '23 18:09 msapcili

This seems to be happening if you're using Firebase SDK Version < 10. I was having this problem when I was using it with Firebase SDK version 9.23.0 and then I updated the Firebase SDK to version 10.5.2 and the problem went away. This means that the issue is with rxfire module that failed to be backward compatible to its complimentary Firebase SDK Version, specifically speaking in respect to the AggregateQuerySnapshot class that expects 2 different types of data for the 2 versions, hence the error.

export type CountSnapshot = lite.AggregateQuerySnapshot<{ count: lite.AggregateField<number>; }, any, DocumentData>; This is only compatible with Firebase SDK versions >10 as it expects 3 generic type datas and failed to be compatible with versions less than 10 that only expect 1 generic type data for AggregateQuerySnapshot.

eyoeldefare avatar Nov 06 '23 23:11 eyoeldefare

@eyoeldefare See the overrides necessary: https://github.com/FirebaseExtended/rxfire/issues/88#issuecomment-1715851191

rgant avatar Nov 07 '23 13:11 rgant

  "overrides": {
    "@angular/fire@~7.6.1": {
      "rxfire@^6.0.0": "6.0.3"
    }
  }

I tried this, I get Override for @angular/fire@^7.6.1 conflicts with direct dependency error when I perform npm install

Steve-from-Memphis avatar Nov 19 '23 18:11 Steve-from-Memphis

@Steve-from-Memphis

I tried this, I get Override for @angular/fire@^7.6.1 conflicts with direct dependency error when I perform npm install

Your "dependency": { "@angular/fire": "version` must match the override version.

rgant avatar Nov 20 '23 16:11 rgant