Working on an Angular 4 project, I am attempting to declare an attribute in a component class that is an object containing multiple arrays, structured like this:
history: {
Movies: Array<Media>,
Images: Array<Media>,
Music: Array<Media>,
};
The Media interface has the following properties:
export interface Media {
size: number,
name: String
}
When trying to push objects into the history elements like this:
this.history.Music.push(music);
Where music
has the same type (Media), it throws the error:
1449 ERROR TypeError: Cannot read property 'Music' of undefined
This issue seems to be related to the declaration.
Note: I have tried declaring the arrays as both empty and with initial values, but the error persists.