I'm using the Firebase Admin SDK in my Express + Typescript server. I'm trying to use Firestore's method withConverter() However, I get the error "Cannot find namespace 'FirebaseFirestore'.ts(2503)". How can I deal with this?
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
const firestore = admin.firestore();
interface BlogpostColletion {
text: String,
title: String,
}
interface UsersCollection {
blogposts: BlogpostColletion
}
const converter = {
toFirestore: (data: UsersCollection) => data,
// PROBLEM HERE👇 "Cannot find namespace 'FirebaseFirestore'.ts(2503)"
fromFirestore: (snap: FirebaseFirestore.QueryDocumentSnapshot) =>
snap.data() as UsersCollection
}
You can import QueryDocumentSnapshot
from Admin SDK like this:
import * as admin from "firebase-admin"
fromFirestore: (snap: admin.firestore.QueryDocumentSnapshot)