how can I to automatically delete family
property? or at least I want to get an error tells class A is not compatible with B.
class A {
name? : string; family : string = "bye";
}
class B {
name? : string;
}
let b : B = new A();
b.name ="hiii";
//b.family = "something" <--- error, which is intended, but the variable still exist...
console.log({...b})
output:
{
"family": "bye",
"name": "hiii"
}
my goal:
{
"name": "hiii"
}
I’m using the spread operator to INSERT items into an sql table, and I want to make sure I have only the defined properties. I can manually map them, but is there no out-of-the-box solution?
thanks for any help attempt.
Note: Utility Types such as Pick and Required will not help since the question here is not about types