Closed
Description
TypeScript Version: 3.6.3
Search Terms: object is possibly undefined
Code
const foo = (bar: { baz?: { name: string } }) => {
const isBarBazDefined = !!bar.baz;
if(isBarBazDefined) console.log(bar.baz.name);
}
Expected behavior:
Typescript should not give an 'object is possibly undefined' error.
Actual behavior:
Typescript does give an 'object is possibly undefined' error.
Related Issues:
Couldn't find any.
I realise this is very simple case, but I haven't been able to find an existing issue or FAQ entry on the subject...