简体   繁体   English

带数组对象的Typescript接口

[英]Typescript interface for object with array

Trying to make an interface for an object that has an optional children field that has an array of the same interface. 尝试为具有可选子字段的对象创建接口,该子字段具有相同接口的数组。

export interface ItemInterface {
  name: string;
  id: number;
  children?: ItemInterface[];
}

This gives me an error of : Type 'ItemInterface' must have a 'Symbol.iterator' method that returns an iterator. 这给我一个错误:类型'ItemInterface'必须具有返回迭代器的'Symbol.iterator'方法。

意外将接口与数组关联-关闭

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM