Check out this example
The concept behind this is having a type that can either be a single object or an array of objects.
type SingleOrArray<T> = T | T[];
The structure in question looks like this:
const area: ItemArea = [
{ name: 'test1' },
{ name: 'test2' },
[
{ name: 'test3' },
{ name: '&l&apos, test4' },
[
{ name: 'test5' },
{ name: 'test6' },
[
{ name: 'test7' },
]
]
]
];
How do I enforce the restriction that each element in this nested array must adhere to the following type:
type Item = { name: string };
Thank you.