有人可以解释为什么我用此代码收到以下FlowJS错误吗?
数字1与字符串[2]不兼容
如果我删除最后一个data = [0, 1, 2, 3, 7, 8, 9, 10]
indices = [1, 1, 0, 0, 0, 2, 1, 0]
# Use max because you really care about the biggest index, not the number of unique indices
# A list comprehension producing [] each time produces a *new* list each time
new_list = [[] for _ in range(max(indices)+1)]
# Iterate each datum and matching index in parallel exactly once
for datum, idx in zip(data, indices):
new_list[idx].append(datum)
,则流错误消失了:
number
即使我很奇怪,如果我将值映射到自己(map()
),也会触发错误。在这种情况下,映射值会使Flow感到困惑吗?
function splitKey(key: string | Array<string | number>): Array<any> {
const arr = typeof key === 'string' ? key.split('.') : key;
return arr.length === 1 && arr[0] === '' ? [] : arr;
}
答案 0 :(得分:2)
由于flow's playground,我们可以看到此错误针对0.83.0出现,但已在0.84.0中出现
很遗憾,我在release notes中没有发现与此问题相关的任何内容,因此根本原因仍然未知。