mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
52 lines
1.1 KiB
TypeScript
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
|
|
}
|