fix(storage): add missing type for StringFormat object values#8530
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
10 tasks
mikehardy
approved these changes
May 12, 2025
Collaborator
There was a problem hiding this comment.
@superguineapig this looks great, thank you! If you sign the CLA I can release this immediately
edit: signed! Thanks
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.
Description
This is a TypeScript Type Only change. The type declarations for the storage module were missing the union type that aggregates the string literal values of the
StringFormat"enum" object. Without this type, theuploadStringfunction's 3rd parameter expects an Object (corresponding to the StringFormat interface) instead of a string that specifies the format of the uploaded data. This causes a TypeScript compile/check error, but does not otherwise affect the functionality of the function implementation.This PR adds the appropriate type declaration to satisfy type checking as described in Firebase docs
Related issues
Release Summary
Checklist
AndroidiOSOther(macOS, web)e2etests added or updated inpackages/\*\*/e2ejesttests added or updated inpackages/\*\*/__tests__Test Plan
I don't believe there is a trivial way to write a Jest test for this issue as it involves a type annotation. In my personal code, a
@ts-ignoreto suppress the error, with subsequent passing of a valid string for the argument resulted in perfectly functional run-time behavior.The changes in this PR remove the need for the error suppression comment and the dev-time string inference is performed as expected.
It may be noted that there already exists a run-time value assertion to ensure the value for the format argument is one of the expected strings.
See:
react-native-firebase/packages/storage/lib/StorageReference.js
Lines 273 to 279 in 8c631e1
🔥
Think
react-native-firebaseis great? Please consider supporting the project with any of the below:React Native FirebaseandInvertaseon Twitter