<!-- BUGS: Please use this template. --> <!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript --> <!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md --> <!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. --> **TypeScript Version:** 2.6.0-dev.201xxxxx **Code** ```ts 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.