例如,假设有以下项目列表:
const items = [
{
key: "amalgama"
},
{
key: "torin"
},
{
key: "mascarpone"
}
]
什么流类型
ItemsKeyTuple
定义应该得到以下检查?
type ItemsKeyTuple = ...some stuff with items...
let a: ItemsKeyTuple;
a = "amalgama" // OK;
a = "tomatoes" // ERROR;
主要思想是在使用内部 if-else、switch 语句时获得即时检查和帮助,考虑到将来某个时刻更改密钥的可能性,并确保我会被
Flow
注意到我需要的地方调整。
附言更新了问题标题,我用错了名字