Skip to content

fix(firestore): restore generic root type exports#8989

Draft
russellwheatley wants to merge 2 commits intomainfrom
issue-8975
Draft

fix(firestore): restore generic root type exports#8989
russellwheatley wants to merge 2 commits intomainfrom
issue-8975

Conversation

@russellwheatley
Copy link
Copy Markdown
Member

Description

Fix a Firestore TypeScript regression where root imports like DocumentSnapshot, Transaction, and WriteBatch resolved to non-generic runtime class declarations instead of the intended public generic types.

This updates the Firestore root export surface and emitted declarations so root-imported Firestore types behave correctly in type positions again, and adds regression coverage for the reported usage patterns.

Why compare-types did not catch it

compare-types currently compares Firestore modular/type files such as types/firestore.d.ts and modular.d.ts, not the package root index.d.ts consumer surface.

Because the generic types already existed in the modular/type declarations, the script saw the Firestore shapes as matching. The regression was in how the root package entrypoint re-exported those symbols for consumers importing from @react-native-firebase/firestore, which sits outside the current compare-types boundary.

Related issues

closes #8975

Release Summary

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
    • Other (macOS, web)
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan


Think react-native-firebase is great? Please consider supporting the project with any of the below:

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-firebase Error Error Apr 21, 2026 9:07am

Request Review

@russellwheatley russellwheatley changed the title Issue 8975 fix(firestore): restore generic root type exports Apr 21, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces generic type support (AppModelType and DbModelType) across the Firestore SDK, including CollectionReference, DocumentReference, DocumentSnapshot, Query, QuerySnapshot, Transaction, and WriteBatch. These changes enable improved type safety when working with custom data models and converters. The review feedback identifies opportunities to simplify type casting in FirestoreTransaction.ts where existing type information makes double-casting redundant.

new DocumentSnapshot(
this._firestore,
data as DocumentSnapshotNativeData,
(documentRef as unknown as DocumentReference<AppModelType, DbModelType>).converter,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The as unknown as cast here is redundant. documentRef is already typed as DocumentReferenceType<AppModelType, DbModelType>, which includes the converter property. Since it has been verified as an instance of DocumentReference on line 81, you can access .converter directly. This is correctly handled without a cast on line 136.

Suggested change
(documentRef as unknown as DocumentReference<AppModelType, DbModelType>).converter,
documentRef.converter,

data as DocumentSnapshotNativeData,
(documentRef as unknown as DocumentReference<AppModelType, DbModelType>).converter,
),
) as unknown as DocumentSnapshotType<AppModelType, DbModelType>,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The as unknown as cast is likely unnecessary here. A direct cast to DocumentSnapshotType<AppModelType, DbModelType> should be sufficient, as the runtime DocumentSnapshot class is compatible with the DocumentSnapshotType interface declaration.

Suggested change
) as unknown as DocumentSnapshotType<AppModelType, DbModelType>,
) as DocumentSnapshotType<AppModelType, DbModelType>,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛] v24 new typescript interface not working

1 participant