Skip to content

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

Merged
merged 2 commits into from
Jul 27, 2021

Conversation

yavorona
Copy link
Contributor

@yavorona yavorona commented Jul 26, 2021

Summary

Use enum to define type in getTypeCastValue in project_config

Issues

@coveralls
Copy link

coveralls commented Jul 26, 2021

Coverage Status

Coverage increased (+0.002%) to 96.979% when pulling eee128a on pnguen/use-enum-variable-type into 1b0c036 on master.

@@ -582,9 +583,10 @@ export const getVariableValueForVariation = function(
* @returns {*} Variable value of the appropriate type, or
* null if the type cast failed
*/

Copy link

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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

@yavorona yavorona requested a review from zashraf1985 July 26, 2021 21:28
Copy link
Contributor

@zashraf1985 zashraf1985 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good!

@yavorona yavorona merged commit 930c473 into master Jul 27, 2021
@yavorona yavorona deleted the pnguen/use-enum-variable-type branch July 27, 2021 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants