I'm confused as to why the compiler is saying that the properties "name" and "surname" don't exist on type "ITest1" within function test1. It's a bit unclear to me:
interface ITest1{
name: string;
surname: string;
age: number;
}
interface ITest2{
city: string;
nation: string;
isEU: boolean;
}
//function test1<ITest1, ITest2>(a:ITest1|ITest2): ITest1|ITest2{
function test1<ITest1, ITest2>(a:ITest1|ITest2): string{
return (a as ITest1).name +
(a as ITest1).surname;
}
let a : ITest1 = {
name:"",
surname:"",
age:0
};
a.name="John";
a.surname="Taylor";
a.age=30;
console.log(test1(a));