如何为使用属性作为列表的对象定义打字稿界面

时间:2018-11-24 00:21:25

标签: typescript

我正在为封闭的API使用TypeScript前端服务。

此API中有一个POST方法,它期望如下所示:

{
   transactionId:10,
   price:123.12,
   item1:"some string",
   item2:"another string",
   item3:"another string",
   item4:"another string",
   item5:"another string",
   // ... until the Nth item(n) ...
}

换句话说。它期望将项目定义为"item" + index,而不是使用简单的数组。

如何在打字稿上定义可以适合此类对象的接口?

0 个答案:

没有答案
相关问题