Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#741 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
firebase, react, typescript
Domain
frontend

Research direction

Start by locating ReactFireOptions and the raw snapshot hooks useFirestoreDoc, useFirestoreDocOnce, and useFirestoreCollection. Review the known limitation tracked in #740, then compare these types with the data hooks. Done means snapshot hooks accept their DocumentSnapshot or QuerySnapshot initialData types while data hooks retain T, with no runtime changes.

Written by the indexing model from the issue text.

Description

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).

Dominant language
TypeScript
Stars
3.6k
Forks
403
Avg merge
4d 19h
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from FirebaseExtended/reactfire

All issues in FirebaseExtended/reactfire

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.