Skip to content

Commit

Permalink
Add comment to explain type cast
Browse files Browse the repository at this point in the history
  • Loading branch information
espressoroaster committed Feb 11, 2018
1 parent 158d2a7 commit 8015021
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/data-pane/wildcard-field-drop-zone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const customWildcardFieldTarget: DropTargetSpec<CustomWildcardFieldDropZoneProps
return;
}

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

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

0 comments on commit 8015021

Please sign in to comment.