typescript merge two types 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 assign two types
// refered to as union types in typescript
interface Foo {
bar:string|boolean;
}