在使用聊天應用程式時,我在嘗試將屬性添加到物件陣列時遇到了問題。
// original array
const authors: User[] = []
//But I wanted to add something like this
const authors: User[] & { otherProperty: string }[] = []
我想我可以將陣列擴展到外面,然后使它成為一個陣列,但是可以用交叉點來做嗎?我真的很好奇
uj5u.com熱心網友回復:
您想將屬性添加到User右側嗎?
const authors: (User & { otherProperty: string })[] = [];
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/414476.html
標籤:
