-
Notifications
You must be signed in to change notification settings - Fork 83
Closed
Description
What I wanted to do
Use @optimizely/react-sdk@^2.4.0
and subsequently @optimizely/optimizely-sdk@^4.1.1
with create-react-app (react-scripts@^3.4.1
)
What I expected to happen
When upgrading from @optimizely/react-sdk@2.3.1
to @optimizely/react-sdk@^2.4.0
the application should build and start correctly.
What actually happened
Multiple Typescript errors,
node_modules/@optimizely/optimizely-sdk/lib/optimizely/index.ts:597:39 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Partial<Record<"feature_key" | "user_id" | "variable_key" | "experiment_key" | "event_key", unknown>>'.
No index signature with a parameter of type 'string' was found on type 'Partial<Record<"feature_key" | "user_id" | "variable_key" | "experiment_key" | "event_key", unknown>>'.
597 if (!stringValidator.validate(stringInputs[key])) {
~~~~~~~~~~~~~~~~~
- Perhaps,
key as "feature_key" | "user_id" | "variable_key" | "experiment_key" | "event_key"
could be used to resolve this.
node_modules/@optimizely/optimizely-sdk/lib/optimizely/index.ts:1192:9 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
No index signature with a parameter of type 'string' was found on type '{}'.
1192 allVariables[variable.key] = this.getFeatureVariableValueFromVariation(featureKey, featureEnabled, decisionObj.variation, variable, userId);
~~~~~~~~~~~~~~~~~~~~~~~~~~
- Perhaps
const allVariables: {[key: string]: unknown} = {};
could be used to fix this.
node_modules/@optimizely/optimizely-sdk/lib/utils/attributes_validator/index.ts:33:18 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
No index signature with a parameter of type 'string' was found on type '{}'.
33 if (typeof attributes[key] === 'undefined') {
~~~~~~~~~~~~~~~
node_modules/@optimizely/optimizely-sdk/lib/utils/fns/index.ts:55:12 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'unknown'.
No index signature with a parameter of type 'string' was found on type 'unknown'.
55 return item[key];
~~~~~~~~~
node_modules/@optimizely/optimizely-sdk/lib/utils/user_profile_service_validator/index.ts:36:16 - error TS7053: Element implicitly has an 'any' type because expression of type '"lookup"' can't be used to index type '{}'.
Property 'lookup' does not exist on type '{}'.
36 if (typeof userProfileServiceInstance['lookup'] !== 'function') {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Perhaps resolving if
userProfileServiceInstance
could not be anunknown
node_modules/@optimizely/optimizely-sdk/lib/utils/user_profile_service_validator/index.ts:38:23 - error TS7053: Element implicitly has an 'any' type because expression of type '"save"' can't be used to index type '{}'.
Property 'save' does not exist on type '{}'.
38 } else if (typeof userProfileServiceInstance['save'] !== 'function') {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jolville, alessbell, jamesovens and vreynolds
Metadata
Metadata
Assignees
Labels
No labels