-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
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.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue