types: initialData in ReactFireOptions<T> should accept snapshot types for snapshot hooks
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- firebase, react, typescript
- Ambito
- frontend
Direzione di ricerca
Inizia individuando ReactFireOptions e gli hook di snapshot useFirestoreDoc, useFirestoreDocOnce e useFirestoreCollection. Esamina la limitazione nota tracciata in #740, quindi confronta questi tipi con gli hook dei dati. Il lavoro è completato quando gli hook di snapshot accettano i rispettivi tipi initialData DocumentSnapshot o QuerySnapshot, mentre gli hook dei dati mantengono T, senza modifiche a runtime.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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).
- Lingua principale
- TypeScript
- Stelle
- 3.6k
- Fork
- 403
- Merge medio
- 5g 1h
- PR unite (30g)
- 10
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di FirebaseExtended/reactfire
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
FirebaseExtended/reactfire#801 ·
-
v5
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
FirebaseExtended/reactfire#793 ·
-
v5
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
FirebaseExtended/reactfire#790 · 2 commenti ·
-
v5
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
FirebaseExtended/reactfire#789 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
FirebaseExtended/reactfire#788 ·
Tutte le issue di FirebaseExtended/reactfire
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
bcgov/bc-wallet-mobile#4761 · 1 commento ·
-
external-issue to-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
area-deployment area-integrations triage:bot-seen
Difficoltà 2/5 Mezza giornata Idoneità per principianti 86/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100