美文网首页
TypeScript 定义一个接口的时候,不推荐使用 Array

TypeScript 定义一个接口的时候,不推荐使用 Array

作者: 愤的小鸟怒 | 来源:发表于2019-08-20 18:07 被阅读0次

如果我们使用这种方法定义 NodesItem 的一个数组属性,tslint 就会报错:
Replace generic-typed Array with array literal: Array<string> (prefer-array-literal)

interface NodesItem {
  children: Array<string>;
}

更推荐如下的写法:

interface NodesItem {
  children: string[];
}

相关文章

网友评论

      本文标题:TypeScript 定义一个接口的时候,不推荐使用 Array

      本文链接:https://www.haomeiwen.com/subject/clcmsctx.html