【发布时间】:2018-10-19 04:01:10
【问题描述】:
我仍在尝试掌握 Flow 的工作原理,谁能解释我为什么这个简单的例子会引发错误?
function say(text: string) {
console.log(text);
}
say('Hello World!'); // This is alright
const text: ?string = 'Hello World!';
say(text); // Error:(219, 5) Cannot call `say` with `text` bound to `text` because null or undefined [1] is incompatible with string [2].
我知道,text 变量可以为 null,但是当我调用 say(text) 时,它显然不是 null。
【问题讨论】:
标签: flowtype