Closed
Description
Bug Report
π Search Terms
Control Flow Analysis
type guard
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about type guard and Control Flow Analysis
β― Playground Link
Playground link with relevant code
π» Code
interface User {
name: string | null
}
function baz(u: User) {
const isValid = u.name !== null
if(isValid) {
// `u.name` should be `string`, but the following error appears:
// User.name: string | null
// Object is possibly 'null'. (2531)
u.name.length
}
}
π Actual behavior
u.name
is of type string | null
π Expected behavior
u.name
should be of type string