Skip to content

Typings for Remote Config defaults (defaultConfig) are missing JSON values #6106

@ceisele-r

Description

@ceisele-r

[REQUIRED] Describe your environment

  • Operating System version: Windows 11
  • Browser version: Chrome 100
  • Firebase SDK version: 8 / 9
  • Firebase Product: remote config

[REQUIRED] Describe the problem

Via Firebase Console, we can set a JSON value for a remote config entry.

But in a (typescript) application, there is no way to set a default JSON value as the typings for defaultConfig only allow a default config value to be either string, number or boolean.

The issue seems to be in these two places:

Steps to reproduce:

Try to set the remote config default value to a JSON value via

remoteConfig.defaultConfig = {
      "myfeatureflag": {
          foo: "bar"
       },
    }

This creates the following Typescript error:

Type '{ [x: string]: { foo: string; }; }' is not assignable to type '{ [key: string]: string | number | boolean; }'.
  'string' index signatures are incompatible.
    Type '{ foo: string; }' is not assignable to type 'string | number | boolean'.ts(2322)

Relevant Code:

See above

Activity

google-oss-bot

google-oss-bot commented on Mar 30, 2022

@google-oss-bot
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

jbalidiong

jbalidiong commented on Apr 1, 2022

@jbalidiong
Contributor

Hi @ceisele-r, thanks for the report. I was able to reproduce the behavior now. Let me check what we can do for this issue or bring someone here that can provide more context about it. I’ll update this thread if I have any information to share.

sceee

sceee commented on Apr 1, 2022

@sceee

@jbalidiong thanks. After working a bit more with it, I am actually unsure whether JSON values defined in the dashboard end up in the web app as string value (JSON.stringify'ed) and that's the reason why only string | number | boolean is allowed...
Would be cool if someone could clarify this.

hsubox76

hsubox76 commented on Apr 4, 2022

@hsubox76
Contributor

Looking at the code, it seems it's stored locally as whatever type of value you put in (number, string, boolean, JSON object), however if you try to get the value using getValue(), it will be returned as a string using String() which, if the value is an object, will be [object Object].

It seems reasonable to add a getJSON() method in the same vein as getNumber(), getBoolean(), and we can make this a feature request.

Rohit3523

Rohit3523 commented on Sep 16, 2024

@Rohit3523

Hello, I have made the changes to add support for getJson method.

Should i go ahead and create a pull request?

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @hsubox76@sceee@google-oss-bot@Rohit3523@ceisele-r

        Issue actions

          Typings for Remote Config defaults (`defaultConfig`) are missing JSON values · Issue #6106 · firebase/firebase-js-sdk