gpt4 book ai didi

typescript 接口(interface) : how to declare a property of Array type?

转载 作者:搜寻专家 更新时间:2023-10-30 22:05:19 25 4
gpt4 key购买 nike

我有以下界面:

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
}

我似乎无法在文档中找到它。如何将此属性正确地放入界面中?

最佳答案

参见 TypeScript basic types :

export interface ITransaction {
...
tags: string[]
...
}

关于 typescript 接口(interface) : how to declare a property of Array type?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46027652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com