Do not check for await expression and always output yield await

This commit is contained in:
Artem Tyurin
2018-05-09 09:09:49 +02:00
parent 4d37c44b92
commit d88210b270
9 changed files with 27 additions and 23 deletions

View File

@@ -143,19 +143,19 @@ namespace ts {
);
}
if (node.expression && node.expression.kind !== SyntaxKind.AwaitExpression) {
return setOriginalNode(
setTextRange(
createYield(
createDownlevelAwait(
visitNode(node.expression, visitor, isExpression)
)
),
node
return setOriginalNode(
setTextRange(
createYield(
createDownlevelAwait(
node.expression
? visitNode(node.expression, visitor, isExpression)
: createVoidZero()
)
),
node
);
}
),
node
);
}
return visitEachChild(node, visitor, context);

View File

@@ -95,7 +95,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
class C2 {
f() {
return __asyncGenerator(this, arguments, function* f_1() {
const x = yield;
const x = yield yield __await(void 0);
});
}
}

View File

@@ -160,8 +160,9 @@ var C2 = /** @class */ (function () {
var x;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/];
case 1:
case 0: return [4 /*yield*/, __await(void 0)];
case 1: return [4 /*yield*/, _a.sent()];
case 2:
x = _a.sent();
return [2 /*return*/];
}

View File

@@ -61,7 +61,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
};
function f2() {
return __asyncGenerator(this, arguments, function* f2_1() {
const x = yield;
const x = yield yield __await(void 0);
});
}
//// [F3.js]

View File

@@ -121,8 +121,9 @@ function f2() {
var x;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/];
case 1:
case 0: return [4 /*yield*/, __await(void 0)];
case 1: return [4 /*yield*/, _a.sent()];
case 2:
x = _a.sent();
return [2 /*return*/];
}

View File

@@ -61,7 +61,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
};
const f2 = function () {
return __asyncGenerator(this, arguments, function* () {
const x = yield;
const x = yield yield __await(void 0);
});
};
//// [F3.js]

View File

@@ -121,8 +121,9 @@ var f2 = function () {
var x;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/];
case 1:
case 0: return [4 /*yield*/, __await(void 0)];
case 1: return [4 /*yield*/, _a.sent()];
case 2:
x = _a.sent();
return [2 /*return*/];
}

View File

@@ -78,7 +78,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
const o2 = {
f() {
return __asyncGenerator(this, arguments, function* f_1() {
const x = yield;
const x = yield yield __await(void 0);
});
}
};

View File

@@ -138,8 +138,9 @@ var o2 = {
var x;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/];
case 1:
case 0: return [4 /*yield*/, __await(void 0)];
case 1: return [4 /*yield*/, _a.sent()];
case 2:
x = _a.sent();
return [2 /*return*/];
}