0
为什么会发生此错误?如果我对单个对象(而不是数组)执行相同的操作,它将起作用。FlowJs - 从阵列<Concrete>转换为阵列时出错<Generic>
编辑 OK,这里是文字与额外的测试。
//@flow
type Generic = {
id: number,
}
type Concrete = {
id: number,
a: number,
}
//------test 1-----------
function f(array: Array<Generic>) { }
//'property `a` (Property not found in object type See also: function call)'
var array: Array<Concrete> = [{ id: 1, a: 2 }]
f(array)
//------test 2------------
var a:Generic = { id: 1 }
var b:Concrete = { id: 2, a: 3 }
//OK
a = b
请将截图中的代码记录为文本,以便将其复制并试用。 –
@PavelZubkou请参阅帖子编辑 – eugenekr