I have a user component that has a variable named user: Employee | Student; In my HTML I have an element
{{ user.coure ?? user.department }}
Now I'm getting an error in my HTML since some properties in Employee are not available on Student interface. I don't want to use "any" type or have different variables e.g. student and employee. What is the best way?
Example of the interface that I'm using:
// user.interface.ts
export BaseUser {
id: number;
firstName: string;
middleName: string;
}
export Employee extends BaseUser {
department: string;
}
export Student extends BaseUser {
course: string;
}