bito-code-review[bot] commented on PR #40865:
URL: https://github.com/apache/superset/pull/40865#issuecomment-4662404827

   <!-- Bito Reply -->
   To make `dropUnsupportedTimeShifts` type-safe and avoid `any`, you can 
replace the `any` type with `unknown` and use a type guard to verify the 
structure of `control.choices`. This ensures that `choice` is indeed a tuple of 
`[string, string]` before accessing `choice[0]`.
   
   ```typescript
     static dropUnsupportedTimeShifts(controlsState: Record<string, unknown>): 
void {
       const control = controlsState?.time_compare as { value?: unknown[]; 
choices?: unknown } | undefined;
       if (!control || !Array.isArray(control.value) || 
!Array.isArray(control.choices)) {
         return;
       }
       const supportedChoices = new Set(
         control.choices
           .filter((c): c is [string, string] => Array.isArray(c) && typeof 
c[0] === 'string')
           .map((choice) => choice[0]),
       );
       // ... rest of the filtering logic
     }
   ```
   
   **superset-frontend/src/explore/controlUtils/standardizedFormData.ts**
   ```
   static dropUnsupportedTimeShifts(controlsState: Record<string, unknown>): 
void {
       const control = controlsState?.time_compare as { value?: unknown[]; 
choices?: unknown } | undefined;
       if (!control || !Array.isArray(control.value) || 
!Array.isArray(control.choices)) {
         return;
       }
       const supportedChoices = new Set(
         control.choices
           .filter((c): c is [string, string] => Array.isArray(c) && typeof 
c[0] === 'string')
           .map((choice) => choice[0]),
       );
       // ... rest of the filtering logic
     }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to