mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
More tests
This commit is contained in:
parent
95e391ec72
commit
bc5c7b654a
@ -3386,6 +3386,7 @@ namespace ts {
|
||||
* 6) - UnaryExpression[?yield]
|
||||
* 7) ~ UnaryExpression[?yield]
|
||||
* 8) ! UnaryExpression[?yield]
|
||||
* 9) await AwaitExpression[?yield]
|
||||
*/
|
||||
function parseSimpleUnaryExpression(): UnaryExpression {
|
||||
switch (token) {
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
//// [castOfAwait.ts]
|
||||
async function f() {
|
||||
return <number> await 0;
|
||||
<number> await 0;
|
||||
typeof await 0;
|
||||
void await 0;
|
||||
await void <string> typeof <number> void await 0;
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +18,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
};
|
||||
function f() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return yield 0;
|
||||
yield 0;
|
||||
typeof yield 0;
|
||||
void yield 0;
|
||||
yield void typeof void yield 0;
|
||||
});
|
||||
}
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
async function f() {
|
||||
>f : Symbol(f, Decl(castOfAwait.ts, 0, 0))
|
||||
|
||||
return <number> await 0;
|
||||
<number> await 0;
|
||||
typeof await 0;
|
||||
void await 0;
|
||||
await void <string> typeof <number> void await 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,30 @@
|
||||
=== tests/cases/compiler/castOfAwait.ts ===
|
||||
async function f() {
|
||||
>f : () => Promise<number>
|
||||
>f : () => Promise<void>
|
||||
|
||||
return <number> await 0;
|
||||
<number> await 0;
|
||||
><number> await 0 : number
|
||||
>await 0 : number
|
||||
>0 : number
|
||||
|
||||
typeof await 0;
|
||||
>typeof await 0 : string
|
||||
>await 0 : number
|
||||
>0 : number
|
||||
|
||||
void await 0;
|
||||
>void await 0 : undefined
|
||||
>await 0 : number
|
||||
>0 : number
|
||||
|
||||
await void <string> typeof <number> void await 0;
|
||||
>await void <string> typeof <number> void await 0 : any
|
||||
>void <string> typeof <number> void await 0 : undefined
|
||||
><string> typeof <number> void await 0 : string
|
||||
>typeof <number> void await 0 : string
|
||||
><number> void await 0 : number
|
||||
>void await 0 : undefined
|
||||
>await 0 : number
|
||||
>0 : number
|
||||
}
|
||||
|
||||
|
||||
12
tests/baselines/reference/castOfYield.errors.txt
Normal file
12
tests/baselines/reference/castOfYield.errors.txt
Normal file
@ -0,0 +1,12 @@
|
||||
tests/cases/compiler/castOfYield.ts(4,14): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/castOfYield.ts (1 errors) ====
|
||||
function* f() {
|
||||
<number> (yield 0);
|
||||
// Unlike await, yield is not allowed to appear in a simple unary expression.
|
||||
<number> yield 0;
|
||||
~~~~~
|
||||
!!! error TS1109: Expression expected.
|
||||
}
|
||||
|
||||
15
tests/baselines/reference/castOfYield.js
Normal file
15
tests/baselines/reference/castOfYield.js
Normal file
@ -0,0 +1,15 @@
|
||||
//// [castOfYield.ts]
|
||||
function* f() {
|
||||
<number> (yield 0);
|
||||
// Unlike await, yield is not allowed to appear in a simple unary expression.
|
||||
<number> yield 0;
|
||||
}
|
||||
|
||||
|
||||
//// [castOfYield.js]
|
||||
function f() {
|
||||
(yield 0);
|
||||
// Unlike await, yield is not allowed to appear in a simple unary expression.
|
||||
;
|
||||
yield 0;
|
||||
}
|
||||
@ -1,4 +1,7 @@
|
||||
// @target: es6
|
||||
async function f() {
|
||||
return <number> await 0;
|
||||
<number> await 0;
|
||||
typeof await 0;
|
||||
void await 0;
|
||||
await void <string> typeof <number> void await 0;
|
||||
}
|
||||
|
||||
5
tests/cases/compiler/castOfYield.ts
Normal file
5
tests/cases/compiler/castOfYield.ts
Normal file
@ -0,0 +1,5 @@
|
||||
function* f() {
|
||||
<number> (yield 0);
|
||||
// Unlike await, yield is not allowed to appear in a simple unary expression.
|
||||
<number> yield 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user