111 lines
3.3 KiB
Text
111 lines
3.3 KiB
Text
=== tests/cases/conformance/controlFlow/controlFlowIIFE.ts ===
|
|
|
|
declare function getStringOrNumber(): string | number;
|
|
>getStringOrNumber : Symbol(getStringOrNumber, Decl(controlFlowIIFE.ts, 0, 0))
|
|
|
|
function f1() {
|
|
>f1 : Symbol(f1, Decl(controlFlowIIFE.ts, 1, 54))
|
|
|
|
let x = getStringOrNumber();
|
|
>x : Symbol(x, Decl(controlFlowIIFE.ts, 4, 7))
|
|
>getStringOrNumber : Symbol(getStringOrNumber, Decl(controlFlowIIFE.ts, 0, 0))
|
|
|
|
if (typeof x === "string") {
|
|
>x : Symbol(x, Decl(controlFlowIIFE.ts, 4, 7))
|
|
|
|
let n = function() {
|
|
>n : Symbol(n, Decl(controlFlowIIFE.ts, 6, 11))
|
|
|
|
return x.length;
|
|
>x.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
|
>x : Symbol(x, Decl(controlFlowIIFE.ts, 4, 7))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
|
|
|
}();
|
|
}
|
|
}
|
|
|
|
function f2() {
|
|
>f2 : Symbol(f2, Decl(controlFlowIIFE.ts, 10, 1))
|
|
|
|
let x = getStringOrNumber();
|
|
>x : Symbol(x, Decl(controlFlowIIFE.ts, 13, 7))
|
|
>getStringOrNumber : Symbol(getStringOrNumber, Decl(controlFlowIIFE.ts, 0, 0))
|
|
|
|
if (typeof x === "string") {
|
|
>x : Symbol(x, Decl(controlFlowIIFE.ts, 13, 7))
|
|
|
|
let n = (function() {
|
|
>n : Symbol(n, Decl(controlFlowIIFE.ts, 15, 11))
|
|
|
|
return x.length;
|
|
>x.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
|
>x : Symbol(x, Decl(controlFlowIIFE.ts, 13, 7))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
|
|
|
})();
|
|
}
|
|
}
|
|
|
|
function f3() {
|
|
>f3 : Symbol(f3, Decl(controlFlowIIFE.ts, 19, 1))
|
|
|
|
let x = getStringOrNumber();
|
|
>x : Symbol(x, Decl(controlFlowIIFE.ts, 22, 7))
|
|
>getStringOrNumber : Symbol(getStringOrNumber, Decl(controlFlowIIFE.ts, 0, 0))
|
|
|
|
let y: number;
|
|
>y : Symbol(y, Decl(controlFlowIIFE.ts, 23, 7))
|
|
|
|
if (typeof x === "string") {
|
|
>x : Symbol(x, Decl(controlFlowIIFE.ts, 22, 7))
|
|
|
|
let n = (z => x.length + y + z)(y = 1);
|
|
>n : Symbol(n, Decl(controlFlowIIFE.ts, 25, 11))
|
|
>z : Symbol(z, Decl(controlFlowIIFE.ts, 25, 17))
|
|
>x.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
|
>x : Symbol(x, Decl(controlFlowIIFE.ts, 22, 7))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
|
>y : Symbol(y, Decl(controlFlowIIFE.ts, 23, 7))
|
|
>z : Symbol(z, Decl(controlFlowIIFE.ts, 25, 17))
|
|
>y : Symbol(y, Decl(controlFlowIIFE.ts, 23, 7))
|
|
}
|
|
}
|
|
|
|
// Repros from #8381
|
|
|
|
let maybeNumber: number | undefined;
|
|
>maybeNumber : Symbol(maybeNumber, Decl(controlFlowIIFE.ts, 31, 3))
|
|
|
|
(function () {
|
|
maybeNumber = 1;
|
|
>maybeNumber : Symbol(maybeNumber, Decl(controlFlowIIFE.ts, 31, 3))
|
|
|
|
})();
|
|
maybeNumber++;
|
|
>maybeNumber : Symbol(maybeNumber, Decl(controlFlowIIFE.ts, 31, 3))
|
|
|
|
if (maybeNumber !== undefined) {
|
|
>maybeNumber : Symbol(maybeNumber, Decl(controlFlowIIFE.ts, 31, 3))
|
|
>undefined : Symbol(undefined)
|
|
|
|
maybeNumber++;
|
|
>maybeNumber : Symbol(maybeNumber, Decl(controlFlowIIFE.ts, 31, 3))
|
|
}
|
|
|
|
let test: string | undefined;
|
|
>test : Symbol(test, Decl(controlFlowIIFE.ts, 40, 3))
|
|
|
|
if (!test) {
|
|
>test : Symbol(test, Decl(controlFlowIIFE.ts, 40, 3))
|
|
|
|
throw new Error('Test is not defined');
|
|
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
|
}
|
|
(() => {
|
|
test.slice(1); // No error
|
|
>test.slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
|
|
>test : Symbol(test, Decl(controlFlowIIFE.ts, 40, 3))
|
|
>slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
|
|
|
|
})();
|