Currently, I am transforming responses into an array of Months and Days, with each Day containing an array of numbers. The logic itself is functioning properly, however, I am encountering a tslint error specifically when attempting to push a value into the day array.
Error - Argument of type 'number' is not assignable to parameter of type 'DayTimeData'.
Below is the interface code that I am utilizing:
export interface SerializeHourValData {
name: string;
data: MonthDateTimeData[];
}
export interface MonthDateTimeData {
[month: number]: DayTimeData[];
}
export interface DayTimeData {
[day: number]: number[];
}
Here is the part of the code where the error is occurring:
public valData: SerializeHourValData[] = [];
// Within this loop, I am retrieving the month and day numbers and utilizing them to store hourly data in the 'day' array.
this.valData[index].data[month] = this.valData[index].data[month] || [];
this.valData[index].data[month][day] = this.valData[index].data[month][day] || [];
for (const key in hourlyData) {
if (key.indexOf('h') > -1) {
this.valData[index].data[month][day].push(+hourlyData[key]); // The tslint error occurs here for '+hourlyData[key]'
}
}
View a snapshot of how the data looks post-serialization here.
Please advise on where I may have made errors within the interface.