ChristianMurphy commented on a change in pull request #9820:
URL: 
https://github.com/apache/incubator-superset/pull/9820#discussion_r427704440



##########
File path: superset-frontend/src/dashboard/util/isValidChild.ts
##########
@@ -105,12 +105,36 @@ const parentMaxDepthLookup = {
   [MARKDOWN_TYPE]: {},
 };
 
-export default function isValidChild({ parentType, childType, parentDepth }) {
+type ParentMaxDepthLookup = typeof parentMaxDepthLookup;
+
+interface IsValidChildProps {
+  parentType?: unknown;
+  childType?: unknown;
+  parentDepth?: unknown;
+}
+
+interface ValidChild<
+  P extends keyof ParentMaxDepthLookup,
+  C extends keyof ParentMaxDepthLookup[P],
+  D extends ParentMaxDepthLookup[P][C]
+> {
+  parentType: P;
+  childType: C;
+  parentDepth: D;
+}
+
+export default function isValidChild<
+  P extends keyof ParentMaxDepthLookup = any,
+  C extends keyof ParentMaxDepthLookup[P] = any,
+  D extends ParentMaxDepthLookup[P][C] = any
+>(child: IsValidChildProps): child is ValidChild<P, C, D> {
+  const { parentType, childType, parentDepth } = child;
   if (!parentType || !childType || typeof parentDepth !== 'number') {

Review comment:
       @graceguo-supercat I removed the generics which were causing confusion.
   The request to make `parentDepth` a `number` and remove the `typeof` check 
causes a cascade affect where two other test suites fail
   
   ```
   Test Suites: 2 failed, 186 passed, 188 total
   Tests:       17 failed, 4 skipped, 1040 passed, 1061 total
   Snapshots:   12 passed, 12 total
   Time:        67.338s, estimated 78s
   ```
   
   specifically `getDropPosition` and `isValidChild` both expect the number 
check.




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