I encountered an typeOf
error related to the default
keyword. Below are the imports I am using:
import { AngularFirestore } from '@angular/fire/compat/firestore';
import { map } from 'rxjs/operators';
import firebase from 'firebase/compat/app';
import 'firebase/compat/firestore';
export class PostsService {
constructor(private afs: AngularFirestore) { }
countViews(postId: any){
const viewCount= {
views: firebase.default.firestore.FieldValue.increment(1) //the issue is with default here
}
this.afs.doc(`posts/${postId}`).update(viewCount).then(() => {
console.log("VIEWS updated"); //this is working
})
}
}
Here are the dependencies listed in my package.json file:
"dependencies": {
"@angular/animations": "^14.2.0",
"@angular/common": "^14.2.0",
"@angular/compiler": "^14.2.0",
"@angular/core": "^14.2.0",
"@angular/fire": "^7.6.1",
"@angular/forms": "^14.2.0",
"@angular/platform-browser": "^14.2.0",
"@angular/platform-browser-dynamic": "^14.2.0",
"@angular/router": "^14.2.0",
"bootstrap": "4.6",
"firebase-tools": "^12.5.2",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
}
The code snippet below aims to track the current number of views on a post.
views: firebase.default.firestore.FieldValue.increment(1)
I have already updated my import statements as mentioned earlier. Although I found a similar question on stackoverflow, the suggested solutions did not resolve the issue for me.