Let's say we have two interfaces First
and Second
:
interface First {
a: string;
b: number;
}
interface Second {
b: number;
c: Date;
}
With intersections it is possible to merge two interfaces:
type FirstSecond = First & Second // {a: string, b: number, c: Date}
But is it possible to make an inner join, so the resultant interface only consists of properties that are declared in both interfaces:
type FirstSecond = First /*inner join here*/ Second // {b: number}
This could especially be helpful for generic types.