为什么类型 zzz 不能分配给类型 (zzz & NgIterable<xxx>) |未定义 |无效的

Why Type zzz is not assignable to type (zzz & NgIterable<xxx>) | undefined | null

在 Angular 9 为什么我会收到此消息: 类型项目不可分配给类型 (Items & NgIterable) |未定义 |空

模型正确。我在数据上没有错误。 代码有效,但我仍然收到此打字稿警告。

myData 的模型如下所示:

interface Item {
  url: string;
  label: string;
}

export interface Items {
  [key:number]: Item ;
}

我的HTML:

<ng-container *ngFor="let card of myData"><!-- here I get the warning -->
some content
</ng-container>

添加:我忘记添加示例数据以使其更清楚。 它是一个像这样的数组:

[
    {
      url: 'todo',
      label: 'Rekeningnummer'
    },
    {
      url: 'todo',
      label: 'Postadres'
    }] 

我通过使用类型 Item[] 而不是 Items 来修复它。

myData: Item[] = [...]

我读到 [key: string]: T 形式的索引可以被认为是始终可选的。所以看来我不能使用?使数组可能为空。

export interface Items {
  [key:number]?: Item ;
}