如何解决我可以使用扩展运算符在Typescript接口定义中定义类型吗?
我可以使用Spread运算符在Typescript接口定义中定义类型吗?
例如:
export type Fruit = {
id: number
fruitName: string
}
export type FruitPrices = {
...Fruit;
prices: Price[];
}
export type Price={
amount: number,pound: number,}
服务器上的JSON是:
{
fruits: [
{
id: 1,fruitName: 'orange',prices: [{amount: 10,pound: 1}]
}
]
}
我可以在这样的传播算子中指定...Fruit
类型吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。