Can someone explain why in the following example, variable z has type number, but within the call f1(x.y), x.y has type number | undefined
const f1 = (value: number) => !!value;
const f2 = (x: { y: number | undefined}): void => {
if (x.y === undefined || !isFinite(x.y)) {
throw new Error('Not a number');
}
const z = x.y; // z & x.y has type number
['stuff', 'here'].find(item => f1(x.y)); // x.y has type number | undefined
};