Currently, I am performing some basic destructuring in Javascript:
//@flow
"use strict";
(function(){
const {a,c} = check(true);
})();
function check(bool:boolean):{|a:string,c:string|}|{||}{
if(bool){
return {
a:"b",
c:"d"
};
}
else{
return Object.freeze({});
}
}
Despite this, Flow is presenting errors.
5: const {a,c} = check(true);
^ property `a`. Property not found in
9: function check(bool:boolean):{|a:string,c:string|}|{||}{
^ object type
5: const {a,c} = check(true);
^ property `c`. Property not found in
9: function check(bool:boolean):{|a:string,c:string|}|{||}{
^ object type
Try out the code on this web compiler link
What exactly is Flow looking for and how can these issues be resolved?