Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#741 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
firebase, react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu bằng cách xác định ReactFireOptions và các snapshot hook useFirestoreDoc, useFirestoreDocOnce và useFirestoreCollection. Xem lại hạn chế đã biết được theo dõi trong #740, sau đó so sánh các kiểu này với các data hook. Được xem là hoàn tất khi các snapshot hook chấp nhận các kiểu initialData DocumentSnapshot hoặc QuerySnapshot tương ứng, trong khi các data hook vẫn giữ T, không có thay đổi lúc chạy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
3.6k
Fork
403
Merge trung bình
5 ngày 1 giờ
Pull request đã merge (30 ngày)
10

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của FirebaseExtended/reactfire

Tất cả issue của FirebaseExtended/reactfire

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.