-
Notifications
You must be signed in to change notification settings - Fork 962
Open
Description
[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:
defaultConfig: { [key: string]: string | number | boolean }; defaultConfig: { [key: string]: string | number | boolean };
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
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
google-oss-bot commentedon Mar 30, 2022
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
jbalidiong commentedon Apr 1, 2022
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 commentedon Apr 1, 2022
@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 commentedon Apr 4, 2022
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 usingString()
which, if the value is an object, will be[object Object]
.It seems reasonable to add a
getJSON()
method in the same vein asgetNumber()
,getBoolean()
, and we can make this a feature request.Rohit3523 commentedon Sep 16, 2024
Hello, I have made the changes to add support for getJson method.
Should i go ahead and create a pull request?