Skip to content

[🔥 ] (Modular) Storage API missing type declaration for StringFormat enum #8524

@superguineapig

Description

@superguineapig

Issue

It appears that the TypeScript declarations for the Modular Storage API is missing the StringFormat type that generates a union of const string VALUES in the StringFormat "enum" object.

This prevents TypeScript from allowing a call to uploadString when specifying a 3rd argument for the format parameter.

Ex:

import { StringFormat, uploadString } from "@react-native-firebase/storage";

const storageRef: FirebaseStorageTypes.Reference = <some storage path reference>
const base64StringData: string = <some base64 encoded string>

await uploadString(
  storageRef,
  base64StringData,
  StringFormat.BASE64, // <-- TypeScript Error: Argument of type 'string' is not assignable to parameter of type 'StringFormat'.ts(2345)
);

The problematic type is the inferred object interface of the StringFormat "enum" object, so the parameter does not accept a string value.

The expected type should be constructed similar to this: via google docs

// rename original import (line 30) to not shadow value type
import SFMT = FirebaseStorageTypes.StringFormat; 
...

// new type
export type StringFormat = (typeof SFMT)[keyof typeof SFMT];

// rest of original file
...
export const StringFormat: FirebaseStorageTypes.StringFormat;
...

Thanks everyone! I love RNFirebase. Been using it since the beginning. Always gets better!

P.S. At a glance, there may be other "enum" style object types like this one missing throughout the modular API.


Project Files

Javascript

Click To Expand

package.json:

"@react-native-firebase/app": "22.1.0",
"@react-native-firebase/storage": "22.1.0",

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  )', __dir__]).strip

platform :ios, min_ios_version_supported
prepare_react_native_project!

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

target 'MyApp' do
  config = use_native_modules!

  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true

  use_react_native!(
    :path => config[:reactNativePath],
    :fabric_enabled => false,
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  #  Add temporary IQKeyboardManagerSwift fork to solve problems with PrivacyInfo.xcprivacy
  # (per https://github.com/douglasjunior/react-native-keyboard-manager/tree/6.5.16-0?tab=readme-ov-file#install)
  pod 'IQKeyboardManagerSwift', :git => 'https://github.com/douglasjunior/IQKeyboardManager.git', :branch => 'react-native-keyboard-manager'

  post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      # :ccache_enabled => true
    )
  end
end

AppDelegate.m:

// N/A


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

 System:
  OS: macOS 15.4.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 149.02 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.16.0
    path: ~/.nvm/versions/node/v20.16.0/bin/node
  Yarn:
    version: 4.5.3
    path: ~/.nvm/versions/node/v20.16.0/bin/yarn
  npm:
    version: 10.8.1
    path: ~/.nvm/versions/node/v20.16.0/bin/npm
  Watchman:
    version: 2025.04.28.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/user/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.4
      - iOS 18.4
      - macOS 15.4
      - tvOS 18.4
      - visionOS 2.4
      - watchOS 11.4
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 16.3/16E140
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 23.0.2
    path: /usr/bin/javac
  Ruby:
    version: 3.3.4
    path: /Users/user/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 22.1.0
  • Firebase module(s) you're using that has the issue:
    • Storage
  • Are you using TypeScript?
    • Y & 5.8.3


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions