Is it possible to conditionally narrow the type of object properties without causing an error when reassigning the whole object to another variable?
type A = {
prop: string | number;
}
type B = {
prop: string;
}
function f(a: A) {
if (typeof a.prop === 'string') {
let str: string = a.prop; // No error
let b: B = a; // Error
}
}