Browse Source

fix(experiments): Declare experiment config as const (#45899)

Malachi Willey 2 years ago
parent
commit
aca2cf267e
2 changed files with 3 additions and 8 deletions
  1. 2 7
      static/app/data/experimentConfig.tsx
  2. 1 1
      static/app/utils/useExperiment.tsx

+ 2 - 7
static/app/data/experimentConfig.tsx

@@ -11,12 +11,7 @@ export const unassignedValue = -1;
 /**
  * Frontend experiment configuration object
  */
-export const experimentList: {
-  assignments: number[] | string[];
-  key: string;
-  parameter: string;
-  type: ExperimentType;
-}[] = [
+export const experimentList = [
   {
     key: 'OnboardingNewFooterExperiment',
     type: ExperimentType.Organization,
@@ -29,7 +24,7 @@ export const experimentList: {
     parameter: 'exposed',
     assignments: [0, 1],
   },
-];
+] as const;
 
 export const experimentConfig = experimentList.reduce(
   (acc, exp) => ({...acc, [exp.key]: exp}),

+ 1 - 1
static/app/utils/useExperiment.tsx

@@ -21,7 +21,7 @@ type UseExperimentOptions = {
 };
 
 type UseExperimentReturnValue<E extends ExperimentKey> = {
-  experimentAssignment: ExperimentAssignment[E];
+  experimentAssignment: ExperimentAssignment[E] | typeof unassignedValue;
   /**
    * Call this method when the user has been exposed to the experiment.
    * You do not need to call this unless you have disabled logging on mount.