Working in Angular/TypeScript, a small question: Say I have a defined object with nested objects, and a blank constructor. (And in this case, it's from a package so I cannot edit it; otherwise I'd add a constructor.)
Currently I initialize it like this:
var childObj = new ChildObj();
childObj.ChildProp = 'my child prop';
var myObj = new MyObj();
myObj.Prop1 = 'foo';
myObj.Prop2 = 'bar';
myObj.ChildProp = childObj;
Is there a less cumbersome way of achieving the above? I don't think object initialization syntax works in JS/TypeScript. I'd love to use that kind of syntax:
var myObj = new MyObj {
Prop1 = 'foo',
Prop2 = 'bar',
ChildObj = new ChildObj {
childObj.ChildProp = 'my child prop'
}
};