TypeScript/tests/cases/conformance/expressions/typeGuards/typeGuardsInWhileStatement.ts
2016-03-25 21:29:58 +01:00

24 lines
495 B
TypeScript

let cond: boolean;
function a(x: string | number) {
while (typeof x === "string") {
x; // string
x = undefined;
}
x; // number
}
function b(x: string | number) {
while (typeof x === "string") {
if (cond) continue;
x; // string
x = undefined;
}
x; // number
}
function c(x: string | number) {
while (typeof x === "string") {
if (cond) break;
x; // string
x = undefined;
}
x; // string | number
}