Skip to content

refactor(database)!: migrate to TypeScript#8977

Merged
mikehardy merged 36 commits into
mainfrom
database-typescript
Apr 30, 2026
Merged

refactor(database)!: migrate to TypeScript#8977
mikehardy merged 36 commits into
mainfrom
database-typescript

Conversation

@russellwheatley

@russellwheatley russellwheatley commented Apr 14, 2026

Copy link
Copy Markdown
Member

Description

Breaking changes

  • breaking removed the modular ServerValue named export from @react-native-firebase/database; consumers must use serverTimestamp() / increment() or the preserved namespaced firebase.database.ServerValue API instead. 352f44a
  • breaking changed modular goOffline(db) and goOnline(db) so they no longer return a chainable value, which breaks consumer code that awaits them or calls .then(...) on them. 461786b
  • breaking aligned the modular TypeScript surface with the firebase-js-sdk, so modular types like DatabaseReference, Query, DataSnapshot, OnDisconnect, and QueryConstraint no longer expose the older namespaced instance-style API in their public typings; TypeScript consumers may need to switch to the function-based modular helpers. db5f53b
  • breaking corrected getServerTime(db) to a synchronous Date return in the modular type surface, so TypeScript consumers that previously treated it as promise-like will need to update their code. a8c2fab

Related issues

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

vercel Bot commented Apr 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
react-native-firebase Error Error Apr 17, 2026 5:34pm

Request Review

@russellwheatley russellwheatley changed the title chore(database): add package tsconfig scaffolding refactor(remote-config)!: migrate to TypeScript Apr 14, 2026
@russellwheatley russellwheatley changed the title refactor(remote-config)!: migrate to TypeScript refactor(database)!: migrate to TypeScript Apr 14, 2026

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

Copy link
Copy Markdown
Contributor

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 migrates the @react-native-firebase/database package to TypeScript, introducing robust type definitions for both modular and namespaced APIs and updating the build infrastructure to use react-native-builder-bob. The changes include refactoring core classes like DatabaseDataSnapshot and DatabaseQuery to .ts and adding a snapshot of the Firebase JS SDK types for comparison. The review feedback suggests aligning the forEach callback signature with the official SDK, removing redundant type casts, and replacing unnecessary as never returns with explicit return statements for better code clarity.

Comment thread packages/database/lib/DatabaseDataSnapshot.ts Outdated
Comment thread packages/database/lib/DatabaseDataSnapshot.ts Outdated
Comment thread packages/database/lib/DatabaseQuery.ts
Comment thread packages/database/lib/DatabaseQuery.ts Outdated
Comment thread packages/database/lib/DatabaseQuery.ts Outdated
Comment thread packages/database/lib/DatabaseQuery.ts Outdated
Comment thread packages/database/lib/DatabaseReference.ts Outdated
Comment thread packages/database/lib/types/namespaced.ts Outdated
@russellwheatley russellwheatley marked this pull request as ready for review April 20, 2026 07:57

@mikehardy mikehardy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

amazing - huge portion of the remaining TS work, ready to go

@russellwheatley

Copy link
Copy Markdown
Member Author

Updated to main and re-pushed to verify things still work since we're not using a merge queue here

release notes will come from the commit, so here's the draft of the commit message pulled from the description:


BREAKING CHANGE: database types now match firebase-js-sdk as closely as possible

Please see https://rnfirebase.io/migrating-to-v25 for help migrating if needed

react-native-firebase has a goal to be a drop-in replacement for firebase-js-sdk, with native extensions and performance. It has always worked that way at the javascript level but the typescript types have been divergent

We are fixing that as we refactor to typescript. Please bear with us as we get closer to our goal of react-native-firebase matching firebase-js-sdk both in functionality where possible, but also in exact typescript typing.

Specifics for Database:

  • removed the modular ServerValue named export from @react-native-firebase/database; consumers must use serverTimestamp() / increment() instead.
  • changed modular goOffline(db) and goOnline(db) so they no longer return a chainable value, which breaks consumer code that awaits them or calls .then(...) on them.
  • aligned the modular TypeScript surface with the firebase-js-sdk, so modular types like DatabaseReference, Query, DataSnapshot, OnDisconnect, and QueryConstraint no longer expose the older namespaced instance-style API in their public typings; TypeScript consumers will need to switch to the function-based modular helpers.
  • corrected getServerTime(db) to a synchronous Date return in the modular type surface, so TypeScript consumers that previously treated it as promise-like will need to update their code.

@mikehardy mikehardy merged commit fc8b839 into main Apr 30, 2026
17 of 19 checks passed
@mikehardy mikehardy deleted the database-typescript branch April 30, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants