Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

types: initialData in ReactFireOptions<T> should accept snapshot types for snapshot hooks

未關閉
#741 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@tyler-reitz 已經在處理了。

開始於 2026年7月17日。

  • #740 來自 @tyler-reitz —— 未關閉

評估

難度
3/5
預估耗時
1-2 天
新手友好度
52/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
firebase, react, typescript
領域
frontend

研究方向

首先定位 ReactFireOptions 以及快照鉤子 useFirestoreDoc、useFirestoreDocOnce 和 useFirestoreCollection。查看 #740 中追蹤的已知限制,然後將這些型別與資料鉤子進行比較。完成的標準是:快照鉤子接受其 DocumentSnapshot 或 QuerySnapshot initialData 型別,而資料鉤子仍保留 T,且不進行任何執行階段變更。

由索引模型根據 Issue 內容生成。

描述

v5

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

  1. Split ReactFireOptions into separate types for data hooks vs snapshot hooks, each with the correct initialData type.
  2. 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).

主要語言
TypeScript
星號
3.6k
分支
403
平均合併
1 天 21 小時
30 天內合併 PR
14

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

FirebaseExtended/reactfire 的其他 Issue

查看 FirebaseExtended/reactfire 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。