File: awaitUnionPromise.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (61 lines) | stat: -rw-r--r-- 1,914 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
=== tests/cases/compiler/awaitUnionPromise.ts ===
// https://github.com/Microsoft/TypeScript/issues/18186

class AsyncEnumeratorDone { };
>AsyncEnumeratorDone : AsyncEnumeratorDone

interface IAsyncEnumerator<T> {
    next1(): Promise<T | AsyncEnumeratorDone>;
>next1 : () => Promise<T | AsyncEnumeratorDone>

    next2(): Promise<T> | Promise<AsyncEnumeratorDone>;
>next2 : () => Promise<T> | Promise<AsyncEnumeratorDone>

    next3(): Promise<T | {}>;
>next3 : () => Promise<T | {}>

    next4(): Promise<T | { x: string }>;
>next4 : () => Promise<T | {    x: string;}>
>x : string
}

async function main() {
>main : () => Promise<void>

    const x: IAsyncEnumerator<number> = null;
>x : IAsyncEnumerator<number>
>null : null

    let a = await x.next1();
>a : number | AsyncEnumeratorDone
>await x.next1() : number | AsyncEnumeratorDone
>x.next1() : Promise<number | AsyncEnumeratorDone>
>x.next1 : () => Promise<number | AsyncEnumeratorDone>
>x : IAsyncEnumerator<number>
>next1 : () => Promise<number | AsyncEnumeratorDone>

    let b = await x.next2();
>b : number | AsyncEnumeratorDone
>await x.next2() : number | AsyncEnumeratorDone
>x.next2() : Promise<AsyncEnumeratorDone> | Promise<number>
>x.next2 : () => Promise<AsyncEnumeratorDone> | Promise<number>
>x : IAsyncEnumerator<number>
>next2 : () => Promise<AsyncEnumeratorDone> | Promise<number>

    let c = await x.next3();
>c : number | {}
>await x.next3() : number | {}
>x.next3() : Promise<number | {}>
>x.next3 : () => Promise<number | {}>
>x : IAsyncEnumerator<number>
>next3 : () => Promise<number | {}>

    let d = await x.next4();
>d : number | { x: string; }
>await x.next4() : number | { x: string; }
>x.next4() : Promise<number | { x: string; }>
>x.next4 : () => Promise<number | { x: string; }>
>x : IAsyncEnumerator<number>
>next4 : () => Promise<number | { x: string; }>
}