Within my Article class, I have a property called Image which is structured like this:
export class Article {
public image:Image;
public images: Image[];
}
If I decide to comment out
this.article.image = new Image();
in the following way:
constructor()
{
this.article = new Article();
//this.article.image = new Image();
}
And then attempt to use
this.article.image.fileName = file.name;
later in my code, an error occurs:
ERROR TypeError: Cannot set property '..' of undefined
Interestingly enough, when trying to add something to an array within the same context, for example:
this.article.images.push(something);
No error is thrown! This raises the question of why there is no error with arrays (even without initializing them) while errors occur with simple objects or non-array variables.