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

27 lines
604 B
TypeScript

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