Skip to content

Commit d88210b

Browse files
author
Artem Tyurin
committed
Do not check for await expression and always output yield await
1 parent 4d37c44 commit d88210b

9 files changed

+27
-23
lines changed

src/compiler/transformers/esnext.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,19 @@ namespace ts {
143143
);
144144
}
145145

146-
if (node.expression && node.expression.kind !== SyntaxKind.AwaitExpression) {
147-
return setOriginalNode(
148-
setTextRange(
149-
createYield(
150-
createDownlevelAwait(
151-
visitNode(node.expression, visitor, isExpression)
152-
)
153-
),
154-
node
146+
return setOriginalNode(
147+
setTextRange(
148+
createYield(
149+
createDownlevelAwait(
150+
node.expression
151+
? visitNode(node.expression, visitor, isExpression)
152+
: createVoidZero()
153+
)
155154
),
156155
node
157-
);
158-
}
156+
),
157+
node
158+
);
159159
}
160160

161161
return visitEachChild(node, visitor, context);

tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
9595
class C2 {
9696
f() {
9797
return __asyncGenerator(this, arguments, function* f_1() {
98-
const x = yield;
98+
const x = yield yield __await(void 0);
9999
});
100100
}
101101
}

tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ var C2 = /** @class */ (function () {
160160
var x;
161161
return __generator(this, function (_a) {
162162
switch (_a.label) {
163-
case 0: return [4 /*yield*/];
164-
case 1:
163+
case 0: return [4 /*yield*/, __await(void 0)];
164+
case 1: return [4 /*yield*/, _a.sent()];
165+
case 2:
165166
x = _a.sent();
166167
return [2 /*return*/];
167168
}

tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
6161
};
6262
function f2() {
6363
return __asyncGenerator(this, arguments, function* f2_1() {
64-
const x = yield;
64+
const x = yield yield __await(void 0);
6565
});
6666
}
6767
//// [F3.js]

tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ function f2() {
121121
var x;
122122
return __generator(this, function (_a) {
123123
switch (_a.label) {
124-
case 0: return [4 /*yield*/];
125-
case 1:
124+
case 0: return [4 /*yield*/, __await(void 0)];
125+
case 1: return [4 /*yield*/, _a.sent()];
126+
case 2:
126127
x = _a.sent();
127128
return [2 /*return*/];
128129
}

tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
6161
};
6262
const f2 = function () {
6363
return __asyncGenerator(this, arguments, function* () {
64-
const x = yield;
64+
const x = yield yield __await(void 0);
6565
});
6666
};
6767
//// [F3.js]

tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ var f2 = function () {
121121
var x;
122122
return __generator(this, function (_a) {
123123
switch (_a.label) {
124-
case 0: return [4 /*yield*/];
125-
case 1:
124+
case 0: return [4 /*yield*/, __await(void 0)];
125+
case 1: return [4 /*yield*/, _a.sent()];
126+
case 2:
126127
x = _a.sent();
127128
return [2 /*return*/];
128129
}

tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
7878
const o2 = {
7979
f() {
8080
return __asyncGenerator(this, arguments, function* f_1() {
81-
const x = yield;
81+
const x = yield yield __await(void 0);
8282
});
8383
}
8484
};

tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ var o2 = {
138138
var x;
139139
return __generator(this, function (_a) {
140140
switch (_a.label) {
141-
case 0: return [4 /*yield*/];
142-
case 1:
141+
case 0: return [4 /*yield*/, __await(void 0)];
142+
case 1: return [4 /*yield*/, _a.sent()];
143+
case 2:
143144
x = _a.sent();
144145
return [2 /*return*/];
145146
}

0 commit comments

Comments
 (0)