Summary
ReactFireOptions<T> types initialData as T, which is correct for the data hooks (useFirestoreDocData, useFirestoreCollectionData, useDatabaseObjectData, etc.). For the raw snapshot hooks, the correct type is the snapshot wrapper, not the unwrapped data type:
| Hook |
Correct initialData type |
useFirestoreDoc |
DocumentSnapshot<T> |
useFirestoreDocOnce |
DocumentSnapshot<T> |
useFirestoreCollection |
QuerySnapshot<T> |
useFirestoreCollectionOnce |
QuerySnapshot<T> |
This mismatch is pre-existing and was silently masked by the T | any widening removed in #740. It is not a regression from that PR.
Options
- Split
ReactFireOptions into separate types for data hooks vs snapshot hooks, each with the correct initialData type.
- Make
initialData generic at the hook level (e.g., initialData?: TSnapshot) independent of the data type T.
Either approach would be a TypeScript-only change with no runtime impact.
Tracked in #740 (known limitation section).
Summary
ReactFireOptions<T>typesinitialDataasT, which is correct for the data hooks (useFirestoreDocData,useFirestoreCollectionData,useDatabaseObjectData, etc.). For the raw snapshot hooks, the correct type is the snapshot wrapper, not the unwrapped data type:initialDatatypeuseFirestoreDocDocumentSnapshot<T>useFirestoreDocOnceDocumentSnapshot<T>useFirestoreCollectionQuerySnapshot<T>useFirestoreCollectionOnceQuerySnapshot<T>This mismatch is pre-existing and was silently masked by the
T | anywidening removed in #740. It is not a regression from that PR.Options
ReactFireOptionsinto separate types for data hooks vs snapshot hooks, each with the correctinitialDatatype.initialDatageneric at the hook level (e.g.,initialData?: TSnapshot) independent of the data typeT.Either approach would be a TypeScript-only change with no runtime impact.
Tracked in #740 (known limitation section).