Although this issue is similar to #40796374, that one revolves around types while I am working with interfaces.
Take a look at the code snippet below:
interface Foo {
name: string;
}
function go() {
let instance: Foo | null = null;
let mutator = () => {
instance = {
name: 'string'
};
};
mutator();
if (instance == null) {
console.log('Instance is null or undefined');
} else {
console.log(instance.name);
}
}
An error message pops up stating 'Property 'name' does not exist on type 'never'.
I'm puzzled by how instance could ever be considered as 'never'. Could anyone provide some insight into this?