1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
=== tests/cases/conformance/controlFlow/controlFlowTruthiness.ts ===
declare function foo(): string | undefined;
>foo : Symbol(foo, Decl(controlFlowTruthiness.ts, 0, 0))
function f1() {
>f1 : Symbol(f1, Decl(controlFlowTruthiness.ts, 1, 43))
let x = foo();
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 4, 7))
>foo : Symbol(foo, Decl(controlFlowTruthiness.ts, 0, 0))
if (x) {
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 4, 7))
x; // string
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 4, 7))
}
else {
x; // string | undefined
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 4, 7))
}
}
function f2() {
>f2 : Symbol(f2, Decl(controlFlowTruthiness.ts, 11, 1))
let x: string | undefined;
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 14, 7))
x = foo();
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 14, 7))
>foo : Symbol(foo, Decl(controlFlowTruthiness.ts, 0, 0))
if (x) {
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 14, 7))
x; // string
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 14, 7))
}
else {
x; // string | undefined
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 14, 7))
}
}
function f3() {
>f3 : Symbol(f3, Decl(controlFlowTruthiness.ts, 22, 1))
let x: string | undefined;
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 25, 7))
if (x = foo()) {
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 25, 7))
>foo : Symbol(foo, Decl(controlFlowTruthiness.ts, 0, 0))
x; // string
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 25, 7))
}
else {
x; // string | undefined
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 25, 7))
}
}
function f4() {
>f4 : Symbol(f4, Decl(controlFlowTruthiness.ts, 32, 1))
let x: string | undefined;
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 35, 7))
if (!(x = foo())) {
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 35, 7))
>foo : Symbol(foo, Decl(controlFlowTruthiness.ts, 0, 0))
x; // string | undefined
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 35, 7))
}
else {
x; // string
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 35, 7))
}
}
function f5() {
>f5 : Symbol(f5, Decl(controlFlowTruthiness.ts, 42, 1))
let x: string | undefined;
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 45, 7))
let y: string | undefined;
>y : Symbol(y, Decl(controlFlowTruthiness.ts, 46, 7))
if (x = y = foo()) {
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 45, 7))
>y : Symbol(y, Decl(controlFlowTruthiness.ts, 46, 7))
>foo : Symbol(foo, Decl(controlFlowTruthiness.ts, 0, 0))
x; // string
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 45, 7))
y; // string | undefined
>y : Symbol(y, Decl(controlFlowTruthiness.ts, 46, 7))
}
else {
x; // string | undefined
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 45, 7))
y; // string | undefined
>y : Symbol(y, Decl(controlFlowTruthiness.ts, 46, 7))
}
}
function f6() {
>f6 : Symbol(f6, Decl(controlFlowTruthiness.ts, 55, 1))
let x: string | undefined;
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 58, 7))
let y: string | undefined;
>y : Symbol(y, Decl(controlFlowTruthiness.ts, 59, 7))
if (x = foo(), y = foo()) {
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 58, 7))
>foo : Symbol(foo, Decl(controlFlowTruthiness.ts, 0, 0))
>y : Symbol(y, Decl(controlFlowTruthiness.ts, 59, 7))
>foo : Symbol(foo, Decl(controlFlowTruthiness.ts, 0, 0))
x; // string | undefined
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 58, 7))
y; // string
>y : Symbol(y, Decl(controlFlowTruthiness.ts, 59, 7))
}
else {
x; // string | undefined
>x : Symbol(x, Decl(controlFlowTruthiness.ts, 58, 7))
y; // string | undefined
>y : Symbol(y, Decl(controlFlowTruthiness.ts, 59, 7))
}
}
|