There are 2 types
type A = {
x: number
y: number
}
type B = {
y: number
z: number
}
How to get type with common properties of that
Based on @kube's answer, you could use generics to create a reusable type:
type Common = {
[P in keyof A & keyof B]: A[P] | B[P];
}
This allows you to create intersections on the fly:
const c: Common = { y: 123 };