I have the following typescript code:-
export class Parent {
name: string;
details: Details = {};
}
export interface Details {
age?: number;
address?: Address};
}
export interface Address {
address1: string;
address2: string;
}
Then I can reference this code to set some values:-
var myOptions = new HSCIC.Visualisation.Services.Parent();
myOptions.name = "Chris";
myOptions.details.age = 25;
myOptions.details.address.address1 = "10 The Lane";
The first two setters are working fine but I get a 'Cannot set property 'address1' of 'undefined'.
If I can set the age property from Details, then why can't I set the address1 property of Address, and how can I fix it?