I'm having a rather ridiculous problem.
An object from a subscribed observable has clearly data in it while printing it to the console, but in actual typescript code, says its undefined.
See for yourself:
initData(): void {
this.backendService.getData().subscribe((depotDays: DepotDayAcc[]) => {
console.log(depotDays)
console.log(depotDays[0])
console.log(depotDays[0].investment)
console.log(depotDays[0]["day"])
console.log('depotDays[0] == undefined', depotDays[0] == undefined)
console.log('depotDays[0].investment == undefined', depotDays[0].investment == undefined)
})
}
constructor(
public day: Date,
public investment: number = -1,
public profit: number = 0,
public value: number = 0,
public percent: number = 0,
public tickers: Set<string> = new Set<string>()) {
}

JSON.parse? If so, then remember that your classconstructoryou posted will not be invoked - so those properties will not be set unless they're in the JSON. When usingJSON.parse(without custom rehydration logic) you must useinterfaceto describe the data you're expecting. (Indeed, thetickersmember looks like anArray<String>to me, not aSet(otherwise Chrome would show"tickers": Set(1)instead of["ADSK"].JSON.parseunless you write type-guards.depotDays[0]is a string, not an object. Your backend is probably encoding it as json twice