interface A {
common: number
onlyA: number
}
interface B {
common: number
onlyB: number
}
function foo(param: A | B) {
if(param.common)
}
In this code, TS autocomplete just show me the props that are common to both objects (common), but I want it to show the props that are unique to each object with a sintax like param?.onlyA
, because I want it to be OR interface A OR interface B.
If instead of |
operator I use &
operator, TS understands that there will always be onlyA or onlyB props, autocomplete like param.onlyA
.