Closed
Description
Steps
use TS 3.3 (latest)
enable all strict checks
have code such as this:
interface Props {
foo?: {
bar: string;
baz: string;
}
}
function hello({foo}: Props) {
const isFooPresent = foo !== undefined;
let bar = isFooPresent ? foo.bar : ''; // Object is possibly 'undefined'.
let baz = isFooPresent ? foo.baz : ''; // Object is possibly 'undefined'.
// but follow code is safe.
// let bar = foo !== undefined ? foo.bar : '';
// let baz = foo !== undefined ? foo.baz : '';
}
Using a const variable to store check result, an error when occur.