I'm quite new to using typescript and I'm wanting to make a simple object that holds data relating to a specific users message logs. Here is the basic structure I have at the minute:
export class UserMessageLog {
date: string;
askedBy: string;
msgLogs: { id: string, detail: string }[];
}
When I try to push an object in the format of { id, detail} to the msgLogs property, I get an error in the console stating the msgLogs is undefined. I'm assuming I need to initialize this property in a constructor perhaps? What's the best way to do that?
msgLogs: { id: string, detail: string }[] = [];