I am currently in the process of developing a TypeScript Vue composable that utilizes Firebase and the vue-concurrency library.
According to the documentation, I need to explicitly type any intermediate values that are yielded.
I am facing a challenge while trying to type a Firebase getDoc
call, as Eslint is flagging an error stating
Unsafe assignment of an 'any' value
that I need to resolve:
import { db } from 'src/firebase/config';
import {
doc,
getDoc,
// DocumentData,
DocumentSnapshot,
} from 'firebase/firestore';
import { useTask } from 'vue-concurrency';
const getDocumentTask = useTask(function* (
signal,
collectionName: string,
documentId: string
) {
const documentReference = doc(db, collectionName, documentId);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const response: DocumentSnapshot = yield getDoc(documentReference); // <-- Eslint error here
const document = {
...response.data(),
id: response.id,
};
return document;
});
export default getDocumentTask;