'Set nested array to a new array

I have an interface called: StringIdTableType[] as:

export type StringIdTableType = IdTableType<string>

export interface IdTableType<T> {
  id: T
}

So the array can be as:

[
  {
    id: ''
  },
  {
    id: ''
  }
]

Now I have a nested array object as:

MyObject
[{
    ...
  },
  NestedList
  [
    {
      ''
    },
    {
      ''
    },
  ],
]

So I'm trying to map a new const of that nested array as:

  const newTableType: StringIdTableType[] = this.myObject.map(x => ({id: x.nestedList}))

But it is throwing an error:

{id: string[];}[] is not assignable to type StringIdTableType[]

Why is trying to get an array inside an array why is it trying to do that if I'm selecting only the nested array? how can I achieve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source