type subProp = { id: string, name: string }; type ParentProps = { subscriptions?: [ { id: string, items: [???Array Of subProp???] } ] }
这种情况在只有类型别名的打字脚本中可行吗?如果是这样,该怎么做?我在网上找不到任何可行的选择。如果没有,还有什么选择?
你可以申报 items 作为a array 属于 subProps 和 subscriptions 作为具有以下类型的数组 id 和 项目 :
items
array
subProps
subscriptions
id
项目
type subProp = { id: string, name: string }; type ParentProps = { subscriptions?: { id: string, items: subProp[]; }[]; }