Files
tsgo/testdata/baselines/reference/submodule/conformance/controlFlowCommaOperator.js

52 lines
1.1 KiB
TypeScript

//// [tests/cases/conformance/controlFlow/controlFlowCommaOperator.ts] ////
//// [controlFlowCommaOperator.ts]
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
}
//// [controlFlowCommaOperator.js]
"use strict";
function f(x) {
let y = false;
let z = 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
}