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; }>
}
|