Closed
Description
TypeScript Version: 2.6.0-dev.201xxxxx
Code
function f(x: string | undefined) {
if (x) {
const l = x.length
}
const y = !!x
if (y) {
// type error with strictNullChecks on.
const l = x.length
}
if (!!x) {
const l = x.length
}
}
Expected behavior:
I would expect this code to compile without errors by simply refactoring some conditions into variables.
Actual behavior:
Unless the entire condition lives inside the if statement, there will be a type error.