Skip to content

Commit 3a4d0b2

Browse files
committed
Add more tests for await
1 parent 63adc5f commit 3a4d0b2

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
=== tests/cases/conformance/types/contextualTypes/asyncFunctions/contextuallyTypeAsyncFunctionAwaitOperand.ts ===
2+
interface Obj { key: "value"; }
3+
>Obj : Symbol(Obj, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 0, 0))
4+
>key : Symbol(Obj.key, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 0, 15))
5+
6+
async function fn1(): Promise<Obj> {
7+
>fn1 : Symbol(fn1, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 0, 31))
8+
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
9+
>Obj : Symbol(Obj, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 0, 0))
10+
11+
const obj1: Obj = await { key: "value" };
12+
>obj1 : Symbol(obj1, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 3, 9))
13+
>Obj : Symbol(Obj, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 0, 0))
14+
>key : Symbol(key, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 3, 29))
15+
16+
const obj2: Obj = await new Promise(resolve => resolve({ key: "value" }));
17+
>obj2 : Symbol(obj2, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 4, 9))
18+
>Obj : Symbol(Obj, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 0, 0))
19+
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
20+
>resolve : Symbol(resolve, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 4, 40))
21+
>resolve : Symbol(resolve, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 4, 40))
22+
>key : Symbol(key, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 4, 60))
23+
24+
return await { key: "value" };
25+
>key : Symbol(key, Decl(contextuallyTypeAsyncFunctionAwaitOperand.ts, 5, 18))
26+
}
27+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
=== tests/cases/conformance/types/contextualTypes/asyncFunctions/contextuallyTypeAsyncFunctionAwaitOperand.ts ===
2+
interface Obj { key: "value"; }
3+
>key : "value"
4+
5+
async function fn1(): Promise<Obj> {
6+
>fn1 : () => Promise<Obj>
7+
8+
const obj1: Obj = await { key: "value" };
9+
>obj1 : Obj
10+
>await { key: "value" } : { key: "value"; }
11+
>{ key: "value" } : { key: "value"; }
12+
>key : "value"
13+
>"value" : "value"
14+
15+
const obj2: Obj = await new Promise(resolve => resolve({ key: "value" }));
16+
>obj2 : Obj
17+
>await new Promise(resolve => resolve({ key: "value" })) : Obj
18+
>new Promise(resolve => resolve({ key: "value" })) : Promise<Obj>
19+
>Promise : PromiseConstructor
20+
>resolve => resolve({ key: "value" }) : (resolve: (value?: Obj | PromiseLike<Obj>) => void) => void
21+
>resolve : (value?: Obj | PromiseLike<Obj>) => void
22+
>resolve({ key: "value" }) : void
23+
>resolve : (value?: Obj | PromiseLike<Obj>) => void
24+
>{ key: "value" } : { key: "value"; }
25+
>key : "value"
26+
>"value" : "value"
27+
28+
return await { key: "value" };
29+
>await { key: "value" } : { key: "value"; }
30+
>{ key: "value" } : { key: "value"; }
31+
>key : "value"
32+
>"value" : "value"
33+
}
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @target: esnext
2+
// @noImplicitAny: true
3+
// @noEmit: true
4+
5+
interface Obj { key: "value"; }
6+
7+
async function fn1(): Promise<Obj> {
8+
const obj1: Obj = await { key: "value" };
9+
const obj2: Obj = await new Promise(resolve => resolve({ key: "value" }));
10+
return await { key: "value" };
11+
}

0 commit comments

Comments
 (0)