TypeScript/tests/cases/conformance/controlFlow/controlFlowCommaOperator.ts

23 lines
545 B
TypeScript
Raw Normal View History

2016-04-20 16:09:43 +02:00
function f(x: string | number | boolean) {
let y: string | number | boolean = false;
let z: string | number | boolean = false;
if (y = "", typeof x === "string") {
x; // string
y; // string
z; // boolean
}
else if (z = 1, typeof x === "number") {
x; // number
y; // string
z; // number
}
else {
x; // boolean
y; // string
z; // number
}
x; // string | number | boolean
y; // string
z; // number | boolean
}