Skip to content

Commit 8015021

Browse files
Add comment to explain type cast
1 parent 158d2a7 commit 8015021

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/components/data-pane/wildcard-field-drop-zone.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ const customWildcardFieldTarget: DropTargetSpec<CustomWildcardFieldDropZoneProps
5656
return;
5757
}
5858

59+
// Casting to DraggedFieldIdentifier because of bad TS type inference
60+
// It does not realize that the object contains the property `fieldDef`
61+
// We do the same thing in `encoding-shelf.tsx for `encodingShelfTarget`
5962
const {fieldDef} = monitor.getItem() as DraggedFieldIdentifier;
6063
const type = fieldDef.type;
6164

@@ -81,6 +84,9 @@ const customWildcardFieldTarget: DropTargetSpec<CustomWildcardFieldDropZoneProps
8184
});
8285
},
8386
canDrop(props, monitor) {
87+
// Casting to DraggedFieldIdentifier because of bad TS type inference
88+
// It does not realize that the object contains the property `fieldDef`
89+
// We do the same thing in `encoding-shelf.tsx for `encodingShelfTarget`
8490
const {fieldDef} = monitor.getItem() as DraggedFieldIdentifier;
8591
return fieldDef.field !== '*';
8692
}

0 commit comments

Comments
 (0)