skip to Main Content

I’m getting a new error in Angular after a maintenance npm upgrade where no direct dependency versions changed.

ng serve produces this error and the build fails:

[ng]
[ng] Error: node_modules/rxfire/firestore/lite/interfaces.d.ts:8:29 - error TS2314: Generic type 'AggregateQuerySnapshot<T>' requires 1 type argument(s).
[ng]
[ng]  8 export type CountSnapshot = lite.AggregateQuerySnapshot<{
[ng]                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ng]  9     count: lite.AggregateField<number>;
[ng]    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ng] 10 }, any, DocumentData>;
[ng]    ~~~~~~~~~~~~~~~~~~~~~
[ng] × Failed to compile.

How can I fix this?

I already reinstalled the full project from scratch. Package dependencies match angular fire instructions:

 "dependencies": {
    "@angular/common": "^15.2.2",
    "@angular/core": "^15.2.2",
    "@angular/fire": "^7.5.0",
    "@angular/forms": "^15.2.2",
    "@angular/platform-browser": "^15.2.2",
    "@angular/platform-browser-dynamic": "^15.2.2",
    "@angular/router": "^15.2.2",
    "@angular/service-worker": "^15.2.2",
    "firebase": "^9.17.1",
    "tslib": "^2.2.0",
    "zone.js": "~0.11.4"
  },

6

Answers


  1. I had the same issue when using [email protected], but issue was fixed when i manually installed the specific version [email protected]

    I took these steps:

    1. Deleted rxfire from my node_modules folder
    2. Manually installed the specific version: npm i [email protected]
    3. Built the app: npm run build
    Login or Signup to reply.
  2. Install the latest version of firebase:

    npm install firebase@latest
    
    Login or Signup to reply.
  3. I got the same error following only the minimal install instructions from the AngularFire repository. So I’m guessing it’s a bug. A quick-and-dirty solution if you just want to ignore the issue is to add skipLibCheck: true to the compilerOptions in your tsconfig.json file in the root directory. That silenced the error so that the app compiled but of course skipping the lib check can introduce other issues so it’s not a production-ready solution.

    Login or Signup to reply.
  4. My project does have "@angular/fire": "7.6.1" as dependency, and not firebase like the OP.

    But in this case, it think it will solve both, as i exactly get the same error from the same origin (node_modules/rxfire/firestore/lite/interfaces.d.ts)

    Downgrading rxfire to version 6.0.4 did not work for me. Downgrading to version 6.0.3 results in a new error, stating

    ‘__spreadArray’ was not found in ‘tslib’

    So there have been two steps to solve (for me):

    1. Overwrite Firebase or @angular/fire module resolution to rxfire in package.json to 6.0.3. I added the way for pnpm as well, if you use this. Remember to replace @angular/fire to firebase, depending on need. Re-install everything afterwards with npm i.

      "pnpm": {
          "overrides": {
              "@angular/fire>rxfire": "6.0.3"
          }
      },
      "overrides": {
          "@angular/fire": {
              "rxfire": "6.0.3"
          }
      }
      
    2. As said, the original error is gone, but there are complaints that some parameters cannot be found in tslib. Surprisingly, I read a lot about updating tslib to the latest version, but that didn’t work. What does work is installing v2.1.0, specifically. Use --save-exact to avoid a version greater than 2.1.0.

      npm i --save-exact [email protected]
      
    Login or Signup to reply.
  5. I resolved this issue by force installing rxfire version 6.0.3

    npm install [email protected]
    

    I had to restart ng serve as well.

    Login or Signup to reply.
  6. I have this error and have angular/fire installed using ng add @angular/fire

    package.json:

    "@angular/core": "^16.0.0",
    "@angular/fire": "^7.6.1",
    

    package.lock.json:

    "firebase": "^9.8.0",
    "rxfire": "^6.0.0",
    

    In node_modules>rxfire>firestore>lite>interface.d.ts

    I changed

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

    to

    export type CountSnapshot = lite.AggregateQuerySnapshot<{
        count: lite.AggregateField<number>;
    }>;
    

    Since the error says it need 1 type of argument, I just leave one.

    I don’t know if it can affect the app, but I don’t plan on using Firestore lite.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search