Skip to content

Commit 8e565fb

Browse files
committed
avoid generated helpers in baseline
1 parent 4827728 commit 8e565fb

File tree

5 files changed

+32
-89
lines changed

5 files changed

+32
-89
lines changed

tests/baselines/reference/controlFlowIIFE.errors.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
error TS2318: Cannot find global type 'IterableIterator'.
2-
error TS2468: Cannot find global value 'Promise'.
31
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.
52
tests/cases/conformance/controlFlow/controlFlowIIFE.ts(72,5): error TS2454: Variable 'v' is used before being assigned.
63

74

8-
!!! error TS2318: Cannot find global type 'IterableIterator'.
9-
!!! error TS2468: Cannot find global value 'Promise'.
10-
==== tests/cases/conformance/controlFlow/controlFlowIIFE.ts (3 errors) ====
5+
==== tests/cases/conformance/controlFlow/controlFlowIIFE.ts (2 errors) ====
116
declare function getStringOrNumber(): string | number;
127

138
function f1() {
@@ -79,8 +74,6 @@ tests/cases/conformance/controlFlow/controlFlowIIFE.ts(72,5): error TS2454: Vari
7974
function f6() {
8075
let v: number;
8176
(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.
8477
v = await 1;
8578
})();
8679
v; // still undefined

tests/baselines/reference/controlFlowIIFE.js

Lines changed: 18 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -74,116 +74,65 @@ function f6() {
7474
}
7575

7676
//// [controlFlowIIFE.js]
77-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
78-
return new (P || (P = Promise))(function (resolve, reject) {
79-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
80-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
81-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
82-
step((generator = generator.apply(thisArg, _arguments || [])).next());
83-
});
84-
};
85-
var __generator = (this && this.__generator) || function (thisArg, body) {
86-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
87-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
88-
function verb(n) { return function (v) { return step([n, v]); }; }
89-
function step(op) {
90-
if (f) throw new TypeError("Generator is already executing.");
91-
while (_) try {
92-
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
93-
if (y = 0, t) op = [0, t.value];
94-
switch (op[0]) {
95-
case 0: case 1: t = op; break;
96-
case 4: _.label++; return { value: op[1], done: false };
97-
case 5: _.label++; y = op[1]; op = [0]; continue;
98-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
99-
default:
100-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
101-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
102-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
103-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
104-
if (t[2]) _.ops.pop();
105-
_.trys.pop(); continue;
106-
}
107-
op = body.call(thisArg, _);
108-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
109-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
110-
}
111-
};
11277
function f1() {
113-
var x = getStringOrNumber();
78+
let x = getStringOrNumber();
11479
if (typeof x === "string") {
115-
var n = function () {
80+
let n = function () {
11681
return x.length;
11782
}();
11883
}
11984
}
12085
function f2() {
121-
var x = getStringOrNumber();
86+
let x = getStringOrNumber();
12287
if (typeof x === "string") {
123-
var n = (function () {
88+
let n = (function () {
12489
return x.length;
12590
})();
12691
}
12792
}
12893
function f3() {
129-
var x = getStringOrNumber();
130-
var y;
94+
let x = getStringOrNumber();
95+
let y;
13196
if (typeof x === "string") {
132-
var n = (function (z) { return x.length + y + z; })(y = 1);
97+
let n = (z => x.length + y + z)(y = 1);
13398
}
13499
}
135100
// Repros from #8381
136-
var maybeNumber;
101+
let maybeNumber;
137102
(function () {
138103
maybeNumber = 1;
139104
})();
140105
maybeNumber++;
141106
if (maybeNumber !== undefined) {
142107
maybeNumber++;
143108
}
144-
var test;
109+
let test;
145110
if (!test) {
146111
throw new Error('Test is not defined');
147112
}
148-
(function () {
113+
(() => {
149114
test.slice(1); // No error
150115
})();
151116
// Repro from #23565
152117
function f4() {
153-
var v;
118+
let v;
154119
(function () {
155120
v = 1;
156121
})();
157122
v;
158123
}
159124
function f5() {
160-
var v;
161-
(function () {
162-
return __generator(this, function (_a) {
163-
switch (_a.label) {
164-
case 0: return [4 /*yield*/, 1];
165-
case 1:
166-
_a.sent();
167-
v = 1;
168-
return [2 /*return*/];
169-
}
170-
});
125+
let v;
126+
(function* () {
127+
yield 1;
128+
v = 1;
171129
})();
172130
v; // still undefined
173131
}
174132
function f6() {
175-
var v;
176-
(function () {
177-
return __awaiter(this, void 0, void 0, function () {
178-
return __generator(this, function (_a) {
179-
switch (_a.label) {
180-
case 0: return [4 /*yield*/, 1];
181-
case 1:
182-
v = _a.sent();
183-
return [2 /*return*/];
184-
}
185-
});
186-
});
133+
let v;
134+
(async function () {
135+
v = await 1;
187136
})();
188137
v; // still undefined
189138
}

tests/baselines/reference/controlFlowIIFE.symbols

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ function f1() {
1616
>n : Symbol(n, Decl(controlFlowIIFE.ts, 5, 11))
1717

1818
return x.length;
19-
>x.length : Symbol(String.length, Decl(lib.d.ts, --, --))
19+
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
2020
>x : Symbol(x, Decl(controlFlowIIFE.ts, 3, 7))
21-
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
21+
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
2222

2323
}();
2424
}
@@ -38,9 +38,9 @@ function f2() {
3838
>n : Symbol(n, Decl(controlFlowIIFE.ts, 14, 11))
3939

4040
return x.length;
41-
>x.length : Symbol(String.length, Decl(lib.d.ts, --, --))
41+
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
4242
>x : Symbol(x, Decl(controlFlowIIFE.ts, 12, 7))
43-
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
43+
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
4444

4545
})();
4646
}
@@ -62,9 +62,9 @@ function f3() {
6262
let n = (z => x.length + y + z)(y = 1);
6363
>n : Symbol(n, Decl(controlFlowIIFE.ts, 24, 11))
6464
>z : Symbol(z, Decl(controlFlowIIFE.ts, 24, 17))
65-
>x.length : Symbol(String.length, Decl(lib.d.ts, --, --))
65+
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
6666
>x : Symbol(x, Decl(controlFlowIIFE.ts, 21, 7))
67-
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
67+
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
6868
>y : Symbol(y, Decl(controlFlowIIFE.ts, 22, 7))
6969
>z : Symbol(z, Decl(controlFlowIIFE.ts, 24, 17))
7070
>y : Symbol(y, Decl(controlFlowIIFE.ts, 22, 7))
@@ -99,13 +99,13 @@ if (!test) {
9999
>test : Symbol(test, Decl(controlFlowIIFE.ts, 39, 3))
100100

101101
throw new Error('Test is not defined');
102-
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
102+
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
103103
}
104104
(() => {
105105
test.slice(1); // No error
106-
>test.slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
106+
>test.slice : Symbol(String.slice, Decl(lib.es5.d.ts, --, --))
107107
>test : Symbol(test, Decl(controlFlowIIFE.ts, 39, 3))
108-
>slice : Symbol(String.slice, Decl(lib.d.ts, --, --))
108+
>slice : Symbol(String.slice, Decl(lib.es5.d.ts, --, --))
109109

110110
})();
111111

tests/baselines/reference/controlFlowIIFE.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ function f5() {
181181
>v : number
182182

183183
(function*() {
184-
>(function*() { yield 1; v = 1; })() : {}
185-
>(function*() { yield 1; v = 1; }) : () => {}
186-
>function*() { yield 1; v = 1; } : () => {}
184+
>(function*() { yield 1; v = 1; })() : IterableIterator<number>
185+
>(function*() { yield 1; v = 1; }) : () => IterableIterator<number>
186+
>function*() { yield 1; v = 1; } : () => IterableIterator<number>
187187

188188
yield 1;
189189
>yield 1 : any

tests/cases/conformance/controlFlow/controlFlowIIFE.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @strictNullChecks: true
2+
// @target: ES2017
23

34
declare function getStringOrNumber(): string | number;
45

0 commit comments

Comments
 (0)