I am currently utilizing Firestore alongside React and Typescript. My goal is to fetch data from Firestore and update it. Despite finding numerous examples online with syntax involving methods, my IDE does not recognize these methods for the types involved.
As of now, I can successfully retrieve data from Firestore using functions like the following:
import { getFirestore, collection, doc, updateDoc } from 'firebase/firestore';
const firestore = getFirestore(config);
function App() {
const collRef = collection(firestore, 'collection');
const docRef = doc(firestore, 'collection/id');
updateDoc(docRef, { test: 1234 }).then(x => console.log(x));
}
However, I have come across examples that utilize method chaining in the following manner:
firebase.firestore().collection('collection').doc('id').set({ test: 1234 });
Despite this, my IDE indicates that none of the types used in this chain possess these methods. Even the official documentation mentions that Reference types should include methods like .get()
, .set()
, and .update()
, yet they are absent.
Although this seems straightforward, I must be overlooking a fundamental element. What could I be missing?