我有以下代码。出于某种原因,Flow 拒绝了它。
class A {}
class B {}
type Intersection = (A | B);
var myMap: {
a: A;
b: B;
} = {
a: new A(),
b: new B()
}
var getter = function (name: string): () => Intersection {
return function (): Intersection {
return myMap[name];
}
}
var bGetter: () => B = getter("b");
我在代码中没有看到错误。但是,Flow 拒绝了它,理由如下:
/srv/webwallet/app/scripts/angularHelper.js:14:22,22:A 此类型与 /srv/webwallet/app/scripts/angularHelper.js:12:7,7:B 不兼容
发现 1 个错误
为什么代码不检查,如何检查?