I want to initialize an instance of a class with an object literal not containing all the elements in the class but whose elements are in the class.
class ATest{
aStr:string;
aNum:number;
result(){return this.aStr + this.aNum;}
}
let test=new ATest;
test={aStr:"hello",aNum:12}; // error, result() is missing in the object literal
What is the way to do that assignment exploiting the most of the validations of ts?
test=Object.assign(test,{aStr:"hello",aNom:12});
would work but then you miss the validation of the input fields - see aNom that's wrong but gets in