const doc = await db.collection(hoge).doc(id).get();
const query = await db.collection(hoge).get();
query.forEach(doc => {
});
上記の二つのdocの方は厳密には前者がDocumentSnapShotで後者がQueryDocumentSnapShotである。
では、これらのdocを同じ変数や引数で受けるために
const someFunc(doc:firestore.QueryDocumentSnapShot | firestore.DocumentSnapShot) => {
}
としなければならないのかと言うと、特にそんなことはない。
QueryDocumentSnapShotはDocumentSnapShotのサブクラスであり、
公式ドキュメントにも、違いはQueryDocumentSnapShotの場合isExistsが常にtrueを返したり、
getDataがundefinedを返すことはない程度であると書いてある。
typescriptで型指定する場合は単にfirestore.DocumentSnapShotでOK。