-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
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...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created