Currently facing a bizarre issue.
Even though the console displays data in an object from a subscribed observable, TypeScript code shows it as undefined.
Take a look:
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)
})
}
https://i.sstatic.net/bOBNN.png
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>()) {
}