Flowjs:谓词函数用作对象属性时无法按预期工作

时间:2018-07-17 16:28:15

标签: javascript flowtype

请检查以下代码,我在做错什么吗?

/* @flow */

function isObject (y: any): boolean %checks {
  return typeof y === "object" && y !== null;
}

const obj = { isObject };

function foo(x: mixed) {
  if(isObject(x)) { // Works as expected
    return x.abc;
  }
}

function foo1(x: mixed) {
  if(obj.isObject(x)) { // Not working as expected
    return x.abc;
  }
}

Open this link to try

0 个答案:

没有答案