Allow await await

This commit is contained in:
Andy Hanson
2016-07-25 11:08:02 -07:00
parent 275dbc7537
commit 52fd0334be
8 changed files with 11 additions and 40 deletions
+2 -5
View File
@@ -3337,10 +3337,7 @@ namespace ts {
function parseAwaitExpression() {
const node = <AwaitExpression>createNode(SyntaxKind.AwaitExpression);
nextToken();
node.expression = token === SyntaxKind.AwaitKeyword
// Forbid `await await`
? <UnaryExpression>createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, Diagnostics.Expression_expected)
: parseSimpleUnaryExpression();
node.expression = parseSimpleUnaryExpression();
return finishNode(node);
}
@@ -3389,7 +3386,7 @@ namespace ts {
* 6) - UnaryExpression[?yield]
* 7) ~ UnaryExpression[?yield]
* 8) ! UnaryExpression[?yield]
* 9) await AwaitExpression[?yield]
* 9) [+Await] await AwaitExpression[?yield]
*/
function parseSimpleUnaryExpression(): UnaryExpression {
switch (token) {
@@ -1,10 +0,0 @@
tests/cases/compiler/awaitAwait.ts(2,11): error TS1109: Expression expected.
==== tests/cases/compiler/awaitAwait.ts (1 errors) ====
async function f() {
await await 0;
~~~~~
!!! error TS1109: Expression expected.
}
-21
View File
@@ -1,21 +0,0 @@
//// [awaitAwait.ts]
async function f() {
await await 0;
}
//// [awaitAwait.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments)).next());
});
};
function f() {
return __awaiter(this, void 0, void 0, function* () {
yield ;
yield 0;
});
}
+2
View File
@@ -4,6 +4,7 @@ async function f() {
typeof await 0;
void await 0;
await void <string> typeof <number> void await 0;
await await 0;
}
@@ -22,5 +23,6 @@ function f() {
typeof yield 0;
void yield 0;
yield void typeof void yield 0;
yield yield 0;
});
}
@@ -6,5 +6,6 @@ async function f() {
typeof await 0;
void await 0;
await void <string> typeof <number> void await 0;
await await 0;
}
@@ -25,6 +25,11 @@ async function f() {
><number> void await 0 : number
>void await 0 : undefined
>await 0 : number
>0 : number
await await 0;
>await await 0 : number
>await 0 : number
>0 : number
}
-4
View File
@@ -1,4 +0,0 @@
// @target: es6
async function f() {
await await 0;
}
+1
View File
@@ -4,4 +4,5 @@ async function f() {
typeof await 0;
void await 0;
await void <string> typeof <number> void await 0;
await await 0;
}