-
Notifications
You must be signed in to change notification settings - Fork 83
feat: Use enum to define type in getTypeCastValue #695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -582,9 +583,10 @@ export const getVariableValueForVariation = function( | |||
* @returns {*} Variable value of the appropriate type, or | |||
* null if the type cast failed | |||
*/ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary?
@@ -203,7 +204,7 @@ export const createProjectConfig = function( | |||
// Converting it to a first-class json type while creating Project Config | |||
feature.variables.forEach((variable) => { | |||
if (variable.type === FEATURE_VARIABLE_TYPES.STRING && variable.subType === FEATURE_VARIABLE_TYPES.JSON) { | |||
variable.type = FEATURE_VARIABLE_TYPES.JSON; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this explicit cast needed for the json
value but it works otherwise for other values without casting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there is no otherwise cases of setting a value of variable.type
besides this one. The FEATURE_VARIABLE_TYPES.JSON is type string
and variable.type
is expected to be VariableType
so we needed to case it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good!
Summary
Use enum to define type in getTypeCastValue in project_config
Issues