Closed
Description
var a: boolean | number | string;
if (typeof a !== 'boolean') {
// a is narrowed to "number | string"
for (var i = 0; i < 1; i++) {
for (var j = 0; j < 1; j++) {}
if (typeof a === 'string') {
// a is narrowed to "string'
for (var j = 0; j < 1; j++) {
a.length; // Error: Property 'length' does not exist on type 'never'.
}
}
}
}
Removing any of the three loops, or the outer type guard, makes the problem disappear.