【发布时间】:2017-10-20 07:13:14
【问题描述】:
Flow 认为以下是安全的:
const a: ?any = {};
if (a!=null) {
console.log(a.toString());
}
...但在以下方面引发错误:
const m: Map<string, string> = new Map();
const iter = m.keys();
const iternext = iter.next();
if (iternext!=null) {
const ignore = iternext.value(); // Flow doesn't like this
}
错误是:
call of method `value`. Function cannot be called on possibly undefined value
这是为什么呢?
使用最新的0.57.3 测试。
【问题讨论】:
标签: javascript flowtype