I have type a and type b, but this should work with any amount of types.
type a = {
first: number
}
type b = {
second: string
third: string
}
I want to create a type that optionally merges all those types, so if it would have the second field, it should have the third field also, but it doesn't have to have them both:
Good:
const aa = {
first: 1,
second: "hi",
third: "hello"
}
const ab = {
first: 1
}
const ac = {
second: "hi",
third: "hello"
}
Bad:
const bb = {
first: 1,
second: "hi"
}
How could I define such a type?