ktmud commented on a change in pull request #18799:
URL: https://github.com/apache/superset/pull/18799#discussion_r818903790



##########
File path: superset-frontend/src/components/Select/utils.ts
##########
@@ -60,7 +61,19 @@ export function findValue<OptionType extends OptionTypeBase>(
   return (Array.isArray(value) ? value : [value]).map(find);
 }
 
-export function hasOption(search: string, options: AntdOptionsType) {
+export function hasOption<VT extends string | number>(
+  value: VT,
+  options?: VT | VT[] | { value: VT } | { value: VT }[],
+) {
+  const optionsArray = ensureIsArray(options);
+  return (
+    optionsArray.find(x =>
+      typeof x === 'object' ? x.value === value : x === value,
+    ) !== undefined

Review comment:
       In general I'd prefer to use `x` in those one liners because sometimes 
you may want to rename the iterable variable as well.




-- 
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