My user component includes a variable called user, which can be either an Employee or a Student. In my HTML, I have an element
{{ user.coure ?? user.department }}
I'm encountering an issue in my HTML because some properties in the Employee interface are not available in the Student interface. I want to avoid using the "any" type or having separate variables for student and employee. What is the recommended solution?
Here is an example of the interface I am working with:
// user.interface.ts
export BaseUser {
id: number;
firstName: string;
middleName: string;
}
export Employee extends BaseUser {
department: string;
}
export Student extends BaseUser {
course: string;
}