types: initialData in ReactFireOptions<T> should accept snapshot types for snapshot hooks
維護者通常 1 天內回覆
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 52/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 冷清
- 技術堆疊
- firebase, react, typescript
- 領域
- frontend
研究方向
首先定位 ReactFireOptions 以及快照鉤子 useFirestoreDoc、useFirestoreDocOnce 和 useFirestoreCollection。查看 #740 中追蹤的已知限制,然後將這些型別與資料鉤子進行比較。完成的標準是:快照鉤子接受其 DocumentSnapshot 或 QuerySnapshot initialData 型別,而資料鉤子仍保留 T,且不進行任何執行階段變更。
由索引模型根據 Issue 內容生成。
描述
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> |
Corrected: this table originally listed a fourth row,
useFirestoreCollectionOnce. No such export exists. The raw snapshot hooks are the three above.
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
ReactFireOptionsinto separate types for data hooks vs snapshot hooks, each with the correctinitialDatatype. - Make
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).
- 主要語言
- TypeScript
- 星號
- 3.6k
- 分支
- 403
- 平均合併
- 1 天 21 小時
- 30 天內合併 PR
- 14
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
FirebaseExtended/reactfire 的其他 Issue
-
難度 5/5 一週以上 新手友好度 38/100
FirebaseExtended/reactfire#801 ·
維護者通常 1 天內回覆
-
v5
難度 4/5 3-5 天 新手友好度 48/100
FirebaseExtended/reactfire#793 ·
維護者通常 1 天內回覆
-
v5
難度 4/5 3-5 天 新手友好度 35/100
FirebaseExtended/reactfire#790 · 2 則留言 ·
維護者通常 1 天內回覆
-
v5
難度 4/5 3-5 天 新手友好度 55/100
FirebaseExtended/reactfire#789 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
FirebaseExtended/reactfire#788 ·
維護者通常 1 天內回覆
查看 FirebaseExtended/reactfire 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 77/100
TomerAberbach/profiler-md#733 ·
維護者通常 1 天內回覆
-
bug priority: medium
難度 2/5 1-3 小時 新手友好度 68/100
brentspine/brents-toasts#143 ·
-
🐛 bug 🗺️ DB Models & Ops
難度 2/5 1-3 小時 新手友好度 83/100
LibreChat-AI/LibreChat#17214 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 67/100
Wavvon/Wavvon-clients#136 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
umami-software/umami#4637 ·
維護者通常 3 天內回覆