This question was previously addressed at: Merge Two Interfaces, with the main distinction being the utilization of the Partial function which constructs a type with all properties of Type set to optional. This utility generates a type that includes all subsets of a given type.:
You have the option to either define a new interface:
interface Ci extends Partial<A>, B {}
or create a type:
type Ct = Partial<A> & B
You can test this out on the TypeScript playground with the following code:
interface A {
a1: string
a2: number
}
interface B {
b1: number
}
interface Ci extends Partial<A>, B {}
type Ct = Partial<A> & B
const interfaceType: Ci = {a1: 'blah', a2: 1, b1: 2}
const typeType: Ct = {a1: 'blah', a2: 1, b1: 2}
const partialInterfaceType: Ci = {b1: 1}
const partialTypeType: Ct = {b1: 1}
console.log('interfaceType', interfaceType)
console.log('typeType', typeType)
console.log('partialInterfaceType', partialInterfaceType)
console.log('partialTypeType', partialTypeType)
Check it out on the TypeScript playground by clicking on this link: Playground