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[]
...
}