You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error TS2318: Cannot find global type 'IterableIterator'.
2
+
error TS2468: Cannot find global value 'Promise'.
3
+
tests/cases/conformance/controlFlow/controlFlowIIFE.ts(64,5): error TS2454: Variable 'v' is used before being assigned.
4
+
tests/cases/conformance/controlFlow/controlFlowIIFE.ts(69,6): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
5
+
tests/cases/conformance/controlFlow/controlFlowIIFE.ts(72,5): error TS2454: Variable 'v' is used before being assigned.
6
+
7
+
8
+
!!! error TS2318: Cannot find global type 'IterableIterator'.
9
+
!!! error TS2468: Cannot find global value 'Promise'.
declare function getStringOrNumber(): string | number;
12
+
13
+
function f1() {
14
+
let x = getStringOrNumber();
15
+
if (typeof x === "string") {
16
+
let n = function() {
17
+
return x.length;
18
+
}();
19
+
}
20
+
}
21
+
22
+
function f2() {
23
+
let x = getStringOrNumber();
24
+
if (typeof x === "string") {
25
+
let n = (function() {
26
+
return x.length;
27
+
})();
28
+
}
29
+
}
30
+
31
+
function f3() {
32
+
let x = getStringOrNumber();
33
+
let y: number;
34
+
if (typeof x === "string") {
35
+
let n = (z => x.length + y + z)(y = 1);
36
+
}
37
+
}
38
+
39
+
// Repros from #8381
40
+
41
+
let maybeNumber: number | undefined;
42
+
(function () {
43
+
maybeNumber = 1;
44
+
})();
45
+
maybeNumber++;
46
+
if (maybeNumber !== undefined) {
47
+
maybeNumber++;
48
+
}
49
+
50
+
let test: string | undefined;
51
+
if (!test) {
52
+
throw new Error('Test is not defined');
53
+
}
54
+
(() => {
55
+
test.slice(1); // No error
56
+
})();
57
+
58
+
// Repro from #23565
59
+
60
+
function f4() {
61
+
let v: number;
62
+
(function() {
63
+
v = 1;
64
+
})();
65
+
v;
66
+
}
67
+
68
+
function f5() {
69
+
let v: number;
70
+
(function*() {
71
+
yield 1;
72
+
v = 1;
73
+
})();
74
+
v; // still undefined
75
+
~
76
+
!!! error TS2454: Variable 'v' is used before being assigned.
77
+
}
78
+
79
+
function f6() {
80
+
let v: number;
81
+
(async function() {
82
+
~~~~~
83
+
!!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
84
+
v = await 1;
85
+
})();
86
+
v; // still undefined
87
+
~
88
+
!!! error TS2454: Variable 'v' is used before being assigned.
0 commit comments