fix: coerce integerValue fields to JS number when reading documents#48
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes Firestore document decoding so REST integerValue fields (serialized as JSON strings) are returned to consumers as JS number, aligning behavior with the Firebase Admin SDK and improving drop-in compatibility.
Changes:
- Coerce
integerValueprimitive fields tonumberduring document field extraction. - Add unit + emulator-backed tests to validate
integerValuecoercion (including nested arrays/maps). - Add a changeset documenting the behavior change and precision implications.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/fields.ts |
Updates primitive extraction to convert integerValue from string → number. |
src/fields.test.ts |
Adds coverage for integer coercion (direct, nested, and via get against emulator). |
.changeset/integer-value-coercion.md |
Documents the minor release + breaking behavior and precision caveat. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…EST document retrieval
alexiglesias93
approved these changes
Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Firestore's REST API serializes integerValue as a JSON string to preserve int64 precision. Previously, fireworkers passed the raw value through, so consumers received "1730404244" (string) instead of 1730404244 (number) — diverging from the Firebase Admin SDK and breaking drop-in replacement for data written by other clients (Admin SDK, console, other languages). Fireworkers itself writes all numbers as doubleValue, which is why the bug hid on internal round-trips.
Breaking change note
This changes the runtime type of integerValue fields for anyone who was working around the bug. Released as a minor bump.