We currently support narrowing a union to a smaller union, or an object to a more strict object.
We do not yet support narrowing a mixed data type to a union of concrete types, for example a function gaurd should produce a function type or a truthy gaurd should produce a union of "never falsey" values (aka everything except null/undefined...).
This would allow code to use type gaurds and produce concrete types from mixed types.
/* getObjectField: (obj: Mixed, key: String) => Object | null*/
function getObjectField(obj, key) {
if (obj && typeof obj === 'object' &&
obj[key] && typeof obj[key] === 'object'
) {
return obj[key];
}
return null;
}