File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
packages/optimizely-sdk/lib Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,8 @@ import {
35
35
FeatureVariable ,
36
36
Variation ,
37
37
OptimizelyVariation ,
38
- VariationVariable ,
38
+ VariableType ,
39
+ VariationVariable
39
40
} from '../../shared_types' ;
40
41
41
42
interface TryCreatingProjectConfigConfig {
@@ -203,7 +204,7 @@ export const createProjectConfig = function(
203
204
// Converting it to a first-class json type while creating Project Config
204
205
feature . variables . forEach ( ( variable ) => {
205
206
if ( variable . type === FEATURE_VARIABLE_TYPES . STRING && variable . subType === FEATURE_VARIABLE_TYPES . JSON ) {
206
- variable . type = FEATURE_VARIABLE_TYPES . JSON ;
207
+ variable . type = FEATURE_VARIABLE_TYPES . JSON as VariableType ;
207
208
delete variable . subType ;
208
209
}
209
210
} ) ;
@@ -582,9 +583,10 @@ export const getVariableValueForVariation = function(
582
583
* @returns {* } Variable value of the appropriate type, or
583
584
* null if the type cast failed
584
585
*/
586
+
585
587
export const getTypeCastValue = function (
586
588
variableValue : string ,
587
- variableType : string ,
589
+ variableType : VariableType ,
588
590
logger : LogHandler
589
591
) : unknown {
590
592
let castValue ;
Original file line number Diff line number Diff line change @@ -124,8 +124,16 @@ export interface Experiment {
124
124
forcedVariations ?: { [ key : string ] : string } ;
125
125
}
126
126
127
+ export enum VariableType {
128
+ BOOLEAN = 'boolean' ,
129
+ DOUBLE = 'double' ,
130
+ INTEGER = 'integer' ,
131
+ STRING = 'string' ,
132
+ JSON = 'json' ,
133
+ }
134
+
127
135
export interface FeatureVariable {
128
- type : string ;
136
+ type : VariableType ;
129
137
key : string ;
130
138
id : string ;
131
139
defaultValue : string ;
You can’t perform that action at this time.
0 commit comments