etr2460 commented on a change in pull request #10426:
URL: 
https://github.com/apache/incubator-superset/pull/10426#discussion_r460609975



##########
File path: superset-frontend/src/components/Menu/MenuObject.tsx
##########
@@ -51,22 +61,20 @@ export default function MenuObject({ label, icon, childs, 
url, index }) {
       eventKey={index}
       title={navTitle}
     >
-      {childs.map((child, index1) =>
-        child === '-' ? (
+      {childs?.map((child: MenuObjectChildProps | string, index1: number) =>
+        typeof child === 'string' && child === '-' ? (
           <MenuItem key={`$${index1}`} divider />
         ) : (
           <MenuItem
-            key={`${child.label}`}
-            href={child.url}
+            key={`${(child as MenuObjectChildProps).label}`}
+            href={(child as MenuObjectChildProps).url}
             eventKey={parseFloat(`${index}.${index1}`)}
           >
-            <i className={`fa ${child.icon}`} />
-            &nbsp; {child.label}
+            <i className={`fa ${(child as MenuObjectChildProps).icon}`} />
+            &nbsp; {(child as MenuObjectChildProps).label}

Review comment:
       Maybe I was a bit unclear. It'd be nice to get rid of all the casting 
here entirely. Maybe something this will remove the need for all casting:
   ```tsx
   {childs?.map((child: MenuObjectChildProps | string, index1: number) => {
     if (typeof child === 'string' && child === '-') {
       return <MenuItem key={`$${index1}`} divider />;
     } else if (typeof child !== 'string') {
       return (
         <MenuItem
           key={child.label}
           href={child.url}
           ...
         </MenuItem>
       );
     else {
       return null;
     }
   }
   ```

##########
File path: superset-frontend/src/components/Menu/LanguagePicker.tsx
##########
@@ -17,15 +17,25 @@
  * under the License.
  */
 import React from 'react';
-import PropTypes from 'prop-types';
 import { NavDropdown, MenuItem } from 'react-bootstrap';
 
-const propTypes = {
-  locale: PropTypes.string.isRequired,
-  languages: PropTypes.object.isRequired,
-};
+export interface LanguageProps {

Review comment:
       naming nit, since this isn't a type for props on a react component, the 
name `Languages` might be better




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

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