Consider the following:
userGroups: IUserGroup[];
this.service.getUserGroups().subscribe(g => this.userGroups = g);
The getUserGroups function returns IUserDifferentGroup[]
. However, both IUserGroup
and IUserDifferentGroup
share the same fields, with IUserGroup
having some additional ones. How can we map the response to a new type?
interface IUserDifferentGroup{
Name: string;
Code: string;
Id: number;
}
interface IUserGroup {
Id: number;
GroupName: string;
Visible: boolean;
IsDefault: boolean;
CanAssociated: boolean;
}