with typescript interfaces, i'd like to include only the keys that i declare in interface itself.
I defined a Person interface as follows:
interface Person {
name: string
surname: string
}
In another snippet i receive a json as follows:
let personFromServer = {
name: "myName",
surname: "mySurname",
age: 16
}
let p : Person = personFromServer;
console.log("I wish p to have only name and surname", p)
When i log the p variable i'd like to have only
{
name: "myName"
surname: "mySurname"
}
But i get the age field too:
{
name: "myName"
surname: "mySurname"
age: 16
}
Is it possible to natively accomplish my desired result, in other words just to include the desired keys (and ignoring the extra keys, cause of information overflow)?
Thank you in advance.