How to convert an array of objects to an array from classes? without a loop?
https://repl.it/repls/YellowSuperficialHexagons
export class Lead {
public value = 'val';
public constructor( init?: Partial<Lead> ) {
Object.assign(this, init);
}
public printOk(){
return this.value + ' ok';
}
}
let arr = [ {'value': '1'}, {'value': '2'} ]
let lead: Lead = new Lead(arr[0]);
console.log(lead.printOk());
const leads:Partial<Lead>[] = arr;
console.log(leads[0].value);
//console.log(leads[0].printOk()); //error