There's a function in my code that accepts two types as parameters.
handleDragging(e: CustomEvent<SelectionHandleDragEventType | GridHandleDragEventType>) {
e.stopPropagation();
const newValue = this.computeValuesFromPosition(e.detail.x, e.detail.y, e.detail.variant);
// other same code
})
The problem arises when GridHandleDragEventType
does not include a property called variant
within its type. In such cases, I'm okay with passing null
, but I keep encountering the TypeScript issue:
Property 'variant' does not exist on type 'GridHandleDragEventType'.
Is there a neat solution to this issue?