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

21 lines
510 B
TypeScript

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