TypeScript接口:如何声明一个数组类型的属性?

5

我有以下接口:

export interface ITransaction {
   id: number;
   description: string;
   category: string;
   tags: array;
   date: string;
   amount: number;
}

显然,我在编辑器中看到了错误,所以我的声明是错误的。正如你所见,tags应该是一个数组。这是JSON格式的数据:

{
   "id": 1,
   "description": "Sandwich",
   "date": "2017-09-01",
   "category": "Take away",
   "tags": ["Holidays"],
   "amount": -2
}

我在文档中找不到这个内容。如何将此属性正确地放入接口中?


1
标签:string[] 或 标签:Array<string> - toskv
1
https://www.typescriptlang.org/docs/handbook/basic-types.html#array - str
1个回答

13

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接