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
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:
rxfire
from mynode_modules
foldernpm i [email protected]
npm run build
Install the latest version of firebase:
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 thecompilerOptions
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.My project does have
"@angular/fire": "7.6.1"
as dependency, and notfirebase
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
So there have been two steps to solve (for me):
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
tofirebase
, depending on need. Re-install everything afterwards withnpm i
.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.I resolved this issue by force installing rxfire version 6.0.3
I had to restart ng serve as well.
I have this error and have angular/fire installed using ng add @angular/fire
package.json:
package.lock.json:
In node_modules>rxfire>firestore>lite>interface.d.ts
I changed
to
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.