From c832444f1efa518d1e066db66ecb82439ce6f456 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 18 Jul 2016 15:54:32 -0700 Subject: [PATCH] Accept baselines plus new linter warnings. --- .../asyncFunctionNoReturnType.errors.txt | 5 +- .../reference/asyncFunctionNoReturnType.js | 46 +++++++++++++++++-- tests/cases/unittests/transpile.ts | 6 +-- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/tests/baselines/reference/asyncFunctionNoReturnType.errors.txt b/tests/baselines/reference/asyncFunctionNoReturnType.errors.txt index a7dbb6ecb64..599bf41a7f2 100644 --- a/tests/baselines/reference/asyncFunctionNoReturnType.errors.txt +++ b/tests/baselines/reference/asyncFunctionNoReturnType.errors.txt @@ -1,5 +1,4 @@ error TS2318: Cannot find global type 'Promise'. -tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS1311: Async functions are only available when targeting ECMAScript 2015 or higher. tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS1057: An async function or method must have a valid awaitable return type. tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS7030: Not all code paths return a value. tests/cases/compiler/asyncFunctionNoReturnType.ts(2,9): error TS2304: Cannot find name 'window'. @@ -7,10 +6,8 @@ tests/cases/compiler/asyncFunctionNoReturnType.ts(3,9): error TS7030: Not all co !!! error TS2318: Cannot find global type 'Promise'. -==== tests/cases/compiler/asyncFunctionNoReturnType.ts (5 errors) ==== +==== tests/cases/compiler/asyncFunctionNoReturnType.ts (4 errors) ==== async () => { - ~~~~~ -!!! error TS1311: Async functions are only available when targeting ECMAScript 2015 or higher. ~~~~~~~~~~~~~ !!! error TS1057: An async function or method must have a valid awaitable return type. ~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/asyncFunctionNoReturnType.js b/tests/baselines/reference/asyncFunctionNoReturnType.js index 1d321eea51c..a3635b85a09 100644 --- a/tests/baselines/reference/asyncFunctionNoReturnType.js +++ b/tests/baselines/reference/asyncFunctionNoReturnType.js @@ -14,8 +14,48 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments)).next()); }); }; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (sent[0] === 1) throw sent[1]; return sent[1]; }, trys: [], stack: [] }, sent, f; + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (1) { + if (_.done) switch (op[0]) { + case 0: return { value: void 0, done: true }; + case 1: case 6: throw op[1]; + case 2: return { value: op[1], done: true }; + } + try { + switch (f = 1, op[0]) { + case 0: case 1: sent = op; break; + case 4: return _.label++, { value: op[1], done: false }; + case 7: op = _.stack.pop(), _.trys.pop(); continue; + default: + var r = _.trys.length > 0 && _.trys[_.trys.length - 1]; + if (!r && (op[0] === 6 || op[0] === 2)) { _.done = 1; continue; } + if (op[0] === 3 && (!r || (op[1] > r[0] && op[1] < r[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < r[1]) { _.label = r[1], sent = op; break; } + if (r && _.label < r[2]) { _.label = r[2], _.stack.push(op); break; } + if (r[2]) { _.stack.pop(); } + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } + catch (e) { op = [6, e]; } + finally { f = 0, sent = void 0; } + } + } + return { + next: function (v) { return step([0, v]); }, + "throw": function (v) { return step([1, v]); }, + "return": function (v) { return step([2, v]); } + }; +}; var _this = this; -(function () { return __awaiter(_this, void 0, void 0, function* () { - if (window) - return; +(function () { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + if (window) + return [2 /*return*/]; + return [2 /*return*/]; + }); }); }); diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index 24db2cbf16a..9581996bdd0 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -231,11 +231,11 @@ var x = 0;`, { }); transpilesCorrectly("Report an error when compiler-options input is empty object", "", { - options: { compilerOptions: { module: {} }} + options: { compilerOptions: { module: { } } } }); transpilesCorrectly("Report an error when compiler-options input is empty string", "", { - options: { compilerOptions: { module: "" }} + options: { compilerOptions: { module: "" } } }); transpilesCorrectly("Support options with lib values", "const a = 10;", { @@ -475,5 +475,5 @@ var x = 0;`, { } } }); - }) + }); }