Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TypeScript接口:如何声明数组类型的属性?_Typescript - Fatal编程技术网

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

TypeScript接口:如何声明数组类型的属性?,typescript,Typescript,我有以下界面: export interface ITransaction { id: number; description: string; category: string; tags: array; date: string; amount: number; } 很明显,我宣布它是错误的,因为我在编辑器中看到了一个错误。如您所见,标记应该是一个数组。以下是JSON格式的数据外观: { "id": 1, "description": "Sa

我有以下界面:

export interface ITransaction {
   id: number;
   description: string;
   category: string;
   tags: array;
   date: string;
   amount: number;
}
很明显,我宣布它是错误的,因为我在编辑器中看到了一个错误。如您所见,标记应该是一个数组。以下是JSON格式的数据外观:

{
   "id": 1,
   "description": "Sandwich",
   "date": "2017-09-01",
   "category": "Take away",
   "tags": ["Holidays"],
   "amount": -2
}
我在文件里找不到这个。如何将此属性正确地放入界面?

请参阅:

标记:字符串[]或标记:数组
export interface ITransaction {
  ...
  tags: string[]
  ...
}