-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed as not planned
Closed as not planned
Copy link
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
π Search Terms
control flow analysis, branch, condition
π Version & Regression Information
Tested in 5.8.2.
β― Playground Link
π» Code
interface Human {
age?: number;
}
function consume(obj: Human) {
obj.age = undefined;
}
const obj: Human = { age: 42 };
if (obj.age) {
consume(obj);
const age: number = obj.age; // Not an error
}π Actual behavior
Assignment of const age: number succeeds with undefined.
π Expected behavior
obj.age is assessed as number | undefined, causing the assignment to fail.
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created