Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 77ed080

Browse files
committed
Fix suppressIndexerAny stuff
1 parent e193777 commit 77ed080

File tree

3 files changed

+20
-28
lines changed

3 files changed

+20
-28
lines changed

packages/js-web-sdk/packages/js-web-sdk/src/Datafile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ export type Experiment = {
101101
}
102102

103103
export type VariableValuesObject = {
104-
[key: string]: VariableValue
104+
[key: string]: VariableValue | null
105105
}

packages/js-web-sdk/packages/js-web-sdk/src/OptimizelySDKWrapper.ts

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@ type TrackEventCallArgs = [
7575
* @implements {IOptimizelySDKWrapper}
7676
*/
7777
export class OptimizelySDKWrapper implements IOptimizelySDKWrapper {
78-
static featureVariableGetters = {
79-
string: 'getFeatureVariableString',
80-
double: 'getFeatureVariableDouble',
81-
boolean: 'getFeatureVariableBoolean',
82-
integer: 'getFeatureVariableInteger',
83-
}
84-
8578
static passthroughConfig: Array<keyof optimizely.Config> = [
8679
'errorHandler',
8780
'eventDispatcher',
@@ -289,12 +282,25 @@ export class OptimizelySDKWrapper implements IOptimizelySDKWrapper {
289282
return {}
290283
}
291284

292-
const variableObj = {}
285+
const variableObj: VariableValuesObject = {}
293286
variableDefs.forEach(({ key, type }) => {
294-
const variableGetFnName = OptimizelySDKWrapper.featureVariableGetters[type]
295-
const value = variableGetFnName ? this.instance[variableGetFnName](feature, key, userId, attributes) : null
296-
297-
variableObj[key] = value
287+
switch(type) {
288+
case 'string':
289+
variableObj[key] = this.instance.getFeatureVariableString(feature, key, userId, attributes)
290+
break;
291+
292+
case 'boolean':
293+
variableObj[key] = this.instance.getFeatureVariableBoolean(feature, key, userId, attributes)
294+
break
295+
296+
case 'integer':
297+
variableObj[key] = this.instance.getFeatureVariableInteger(feature, key, userId, attributes)
298+
break
299+
300+
case 'double':
301+
variableObj[key] = this.instance.getFeatureVariableDouble(feature, key, userId, attributes)
302+
break
303+
}
298304
})
299305

300306
return variableObj
@@ -490,19 +496,6 @@ export class OptimizelySDKWrapper implements IOptimizelySDKWrapper {
490496
}
491497
}
492498

493-
/**
494-
* Get options passed in to initialConfig to instantiate every new client with
495-
*/
496-
private getInstantiationOptions(): Partial<{[k in keyof optimizely.Config]: any}> {
497-
const opts = {}
498-
OptimizelySDKWrapper.passthroughConfig.forEach(key => {
499-
if (this.initialConfig[key]) {
500-
opts[key] = this.initialConfig[key]
501-
}
502-
})
503-
return opts
504-
}
505-
506499
private onInitialized() {
507500
const datafile = this.resourceManager.datafile.value
508501
this.userId = this.resourceManager.userId.value || null
@@ -518,8 +511,8 @@ export class OptimizelySDKWrapper implements IOptimizelySDKWrapper {
518511

519512
this.isInitialized = true
520513
this.instance = optimizely.createInstance({
514+
...this.initialConfig,
521515
datafile: this.datafile,
522-
...this.getInstantiationOptions(),
523516
})
524517
// TODO: make sure this is flushed after notification listeners can be added
525518
this.flushTrackEventQueue()

packages/js-web-sdk/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"noImplicitAny": true,
1212
"importHelpers": false,
1313
"strictNullChecks": true,
14-
"suppressImplicitAnyIndexErrors": true,
1514
"noLib": false,
1615
"emitDecoratorMetadata": true,
1716
"experimentalDecorators": true,

0 commit comments

Comments
 (0)