I am brand new to Typescript and have been able to make progress in various areas, but I'm struggling with creating interfaces for deeply nested objects containing "taskName" and "totalTaskHours". The data structure is as follows:
[
{
"20229622": [
{
"taskName": "Project Management",
"totalTaskHours": "1589.4"
},
{
"taskName": "Marketing",
"totalTaskHours": "1306.8"
},
{
"taskName": "Design",
"totalTaskHours": "212.4"
},
{
"taskName": "Programming",
"totalTaskHours": "415.8"
}
]
},
{
"20229623": [
{
"taskName": "Project Management",
"totalTaskHours": "980.1"
},
{
"taskName": "Marketing",
"totalTaskHours": "717.3"
},
{
"taskName": "Design",
"totalTaskHours": "468.9"
}
]
},
{
"20229624": [
{
"taskName": "Programming",
"totalTaskHours": "5930.1"
},
{
"taskName": "Project Management",
"totalTaskHours": "997.2"
},
{
"taskName": "Marketing",
"totalTaskHours": "2108.69"
},
{
"taskName": "Design",
"totalTaskHours": "529.2"
}
]
}
]
Despite my attempts to access the deeply nested objects within the array, I keep encountering errors.
I've tried defining interfaces like this (which obviously didn't work):
interface TaskItem {
taskName: string;
totalTaskHours: string;
}
interface TaskItemArray {
[key:string]: {
[key:string]: TaskItem[];
};
}
interface TaskBreakdownSummedByCategory {
[key:string]: TaskItemArray[];
}
I also attempted the following, but the data structure was too shallow:
interface TaskItem {
taskName: string;
totalTaskHours: string;
}
interface TaskBreakdownSummedByCategory {
[key:string]: TaskItem;
}
Could someone quickly provide some assistance with this issue? I'm still learning and the basic tutorials I've found don't cover deep nested objects. Thanks!