Consider 2 interfaces,
interface Item {
id: string
name: string
budget: number
}
interface Aggregate {
budget: number
estimation: number
}
How to define an interface which is an intersection of Item
and Aggregate
? By intersection I mean the result type should specify properties which exist both in the first and in the second type? In the example above the result should be
interface ItemAndAggregate {
budget: number
}
There's Item & Aggregate
in TypeScript which is called intersection
, but in my opinion the naming is not very correct, because from boolean algebra perspective it's conjunction, A ∪ B
. What I'm looking for is the real intersection, disjunction, A ∩ B
.