I am currently wrapping my firebase calls in a function so that I can define the return type in the function, thus defining the type of a document however you have to turn the firebase call into unknown then into the interface you want otherwise typescript complains. Is there a better way to do this?
Example:
async function getAllPartials() {
const partialDocs = await db.collection('partials').get();
return partialDocs.docs.map(d => d.data()) as unknown as Array<Partial>
}
I also tried:
async function getAllPartials() {
const partialDocs = await db.collection<Partial>('partials').get();
return partialDocs.docs.map(d => d.data())
}
This says: Expected 0 type arguments but got 1;