Skip to content

feat: Use enum to define type in getTypeCastValue#695

Merged
yavorona merged 2 commits into
masterfrom
pnguen/use-enum-variable-type
Jul 27, 2021
Merged

feat: Use enum to define type in getTypeCastValue#695
yavorona merged 2 commits into
masterfrom
pnguen/use-enum-variable-type

Conversation

@yavorona
Copy link
Copy Markdown
Contributor

@yavorona yavorona commented Jul 26, 2021

Summary

Use enum to define type in getTypeCastValue in project_config

Issues

@coveralls
Copy link
Copy Markdown

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.

* @returns {*} Variable value of the appropriate type, or
* null if the type cast failed
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this necessary?

// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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