TypeScript Version: 2.3.4
Code
const foo = (bar?: { baz: number }) => {
if (bar == null) {
bar = { baz: 0 };
}
const baz = () => {
console.log(bar.baz); // Object is possibly undefined
};
baz();
};
Playground link
Expected behavior:
No error
Actual behavior:
Error "Object is possibly undefined"