mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Allow await await
This commit is contained in:
@@ -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.
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
// @target: es6
|
||||
async function f() {
|
||||
await await 0;
|
||||
}
|
||||
@@ -4,4 +4,5 @@ async function f() {
|
||||
typeof await 0;
|
||||
void await 0;
|
||||
await void <string> typeof <number> void await 0;
|
||||
await await 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user