declaration merge typescript code example
Example 1: merge two types typescript
interface IStudent {
id: string;
age: number;
}
interface IWorker {
companyId: string;
}
type IStudentAlias = IStudent;
type ICustomType = IStudent | IWorker;
let s: IStudentAlias = {
id: 'ID3241',
age: 2
};
Example 2: typescript utility types merge interfaces
interface A {
x: string
}
interface B extends Omit<A, 'x'> {
x: number
}