|
| 1 | +//// [tests/cases/conformance/asyncGenerators/asyncGeneratorPromiseNextType.ts] //// |
| 2 | + |
| 3 | +=== asyncGeneratorPromiseNextType.ts === |
| 4 | +// https://github.com/microsoft/TypeScript/issues/44808 |
| 5 | + |
| 6 | +type Result = {message: string} |
| 7 | +>Result : Symbol(Result, Decl(asyncGeneratorPromiseNextType.ts, 0, 0)) |
| 8 | +>message : Symbol(message, Decl(asyncGeneratorPromiseNextType.ts, 2, 15)) |
| 9 | + |
| 10 | +async function *saverGen(): AsyncGenerator<void, void, Promise<Result> | undefined> { |
| 11 | +>saverGen : Symbol(saverGen, Decl(asyncGeneratorPromiseNextType.ts, 2, 31)) |
| 12 | +>AsyncGenerator : Symbol(AsyncGenerator, Decl(lib.es2018.asyncgenerator.d.ts, --, --)) |
| 13 | +>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, --, --)) |
| 14 | +>Result : Symbol(Result, Decl(asyncGeneratorPromiseNextType.ts, 0, 0)) |
| 15 | + |
| 16 | + let pending: Promise<Result>[] = []; |
| 17 | +>pending : Symbol(pending, Decl(asyncGeneratorPromiseNextType.ts, 5, 7)) |
| 18 | +>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, --, --)) |
| 19 | +>Result : Symbol(Result, Decl(asyncGeneratorPromiseNextType.ts, 0, 0)) |
| 20 | + |
| 21 | + while (true) { |
| 22 | + const p: Promise<Result> | undefined = yield; |
| 23 | +>p : Symbol(p, Decl(asyncGeneratorPromiseNextType.ts, 7, 13)) |
| 24 | +>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, --, --)) |
| 25 | +>Result : Symbol(Result, Decl(asyncGeneratorPromiseNextType.ts, 0, 0)) |
| 26 | + |
| 27 | + if (p != null) |
| 28 | +>p : Symbol(p, Decl(asyncGeneratorPromiseNextType.ts, 7, 13)) |
| 29 | + |
| 30 | + pending.push(p); |
| 31 | +>pending.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) |
| 32 | +>pending : Symbol(pending, Decl(asyncGeneratorPromiseNextType.ts, 5, 7)) |
| 33 | +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) |
| 34 | +>p : Symbol(p, Decl(asyncGeneratorPromiseNextType.ts, 7, 13)) |
| 35 | + |
| 36 | + else { |
| 37 | + const results = await Promise.all(pending); |
| 38 | +>results : Symbol(results, Decl(asyncGeneratorPromiseNextType.ts, 11, 17)) |
| 39 | +>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) |
| 40 | +>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, --, --)) |
| 41 | +>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) |
| 42 | +>pending : Symbol(pending, Decl(asyncGeneratorPromiseNextType.ts, 5, 7)) |
| 43 | + |
| 44 | + pending = []; |
| 45 | +>pending : Symbol(pending, Decl(asyncGeneratorPromiseNextType.ts, 5, 7)) |
| 46 | + |
| 47 | + console.log('Storing...'); |
| 48 | +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) |
| 49 | +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) |
| 50 | +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) |
| 51 | + |
| 52 | + await storeResults(results); |
| 53 | +>storeResults : Symbol(storeResults, Decl(asyncGeneratorPromiseNextType.ts, 17, 1)) |
| 54 | +>results : Symbol(results, Decl(asyncGeneratorPromiseNextType.ts, 11, 17)) |
| 55 | + } |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +function storeResults(results: Result[]) { |
| 60 | +>storeResults : Symbol(storeResults, Decl(asyncGeneratorPromiseNextType.ts, 17, 1)) |
| 61 | +>results : Symbol(results, Decl(asyncGeneratorPromiseNextType.ts, 19, 22)) |
| 62 | +>Result : Symbol(Result, Decl(asyncGeneratorPromiseNextType.ts, 0, 0)) |
| 63 | + |
| 64 | + console.log(results); |
| 65 | +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) |
| 66 | +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) |
| 67 | +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) |
| 68 | +>results : Symbol(results, Decl(asyncGeneratorPromiseNextType.ts, 19, 22)) |
| 69 | + |
| 70 | + return Promise.resolve(); |
| 71 | +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) |
| 72 | +>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, --, --)) |
| 73 | +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) |
| 74 | +} |
| 75 | + |
| 76 | +async function *saverGen2() { |
| 77 | +>saverGen2 : Symbol(saverGen2, Decl(asyncGeneratorPromiseNextType.ts, 22, 1)) |
| 78 | + |
| 79 | + let pending: Promise<Result>[] = []; |
| 80 | +>pending : Symbol(pending, Decl(asyncGeneratorPromiseNextType.ts, 25, 7)) |
| 81 | +>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, --, --)) |
| 82 | +>Result : Symbol(Result, Decl(asyncGeneratorPromiseNextType.ts, 0, 0)) |
| 83 | + |
| 84 | + while (true) { |
| 85 | + const p: Promise<Result> | undefined = yield; |
| 86 | +>p : Symbol(p, Decl(asyncGeneratorPromiseNextType.ts, 27, 13)) |
| 87 | +>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, --, --)) |
| 88 | +>Result : Symbol(Result, Decl(asyncGeneratorPromiseNextType.ts, 0, 0)) |
| 89 | + |
| 90 | + if (p != null) |
| 91 | +>p : Symbol(p, Decl(asyncGeneratorPromiseNextType.ts, 27, 13)) |
| 92 | + |
| 93 | + pending.push(p); |
| 94 | +>pending.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) |
| 95 | +>pending : Symbol(pending, Decl(asyncGeneratorPromiseNextType.ts, 25, 7)) |
| 96 | +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) |
| 97 | +>p : Symbol(p, Decl(asyncGeneratorPromiseNextType.ts, 27, 13)) |
| 98 | + |
| 99 | + else { |
| 100 | + const results = await Promise.all(pending); |
| 101 | +>results : Symbol(results, Decl(asyncGeneratorPromiseNextType.ts, 31, 17)) |
| 102 | +>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) |
| 103 | +>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, --, --)) |
| 104 | +>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) |
| 105 | +>pending : Symbol(pending, Decl(asyncGeneratorPromiseNextType.ts, 25, 7)) |
| 106 | + |
| 107 | + pending = []; |
| 108 | +>pending : Symbol(pending, Decl(asyncGeneratorPromiseNextType.ts, 25, 7)) |
| 109 | + |
| 110 | + console.log('Storing...'); |
| 111 | +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) |
| 112 | +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) |
| 113 | +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) |
| 114 | + |
| 115 | + await storeResults(results); |
| 116 | +>storeResults : Symbol(storeResults, Decl(asyncGeneratorPromiseNextType.ts, 17, 1)) |
| 117 | +>results : Symbol(results, Decl(asyncGeneratorPromiseNextType.ts, 31, 17)) |
| 118 | + } |
| 119 | + } |
| 120 | +} |
| 121 | + |
0 commit comments