mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 01:33:08 -05:00
Add support for awaiting union types with mixed promise and non-promise constituents.
This commit is contained in:
24
tests/baselines/reference/awaitUnion_es6.js
Normal file
24
tests/baselines/reference/awaitUnion_es6.js
Normal file
@@ -0,0 +1,24 @@
|
||||
//// [awaitUnion_es6.ts]
|
||||
declare let a: number | string;
|
||||
declare let b: PromiseLike<number> | PromiseLike<string>;
|
||||
declare let c: PromiseLike<number | string>;
|
||||
declare let d: number | PromiseLike<string>;
|
||||
declare let e: number | PromiseLike<number | string>;
|
||||
async function f() {
|
||||
let await_a = await a;
|
||||
let await_b = await b;
|
||||
let await_c = await c;
|
||||
let await_d = await d;
|
||||
let await_e = await e;
|
||||
}
|
||||
|
||||
//// [awaitUnion_es6.js]
|
||||
function f() {
|
||||
return __awaiter([this], function* () {
|
||||
let await_a = yield a;
|
||||
let await_b = yield b;
|
||||
let await_c = yield c;
|
||||
let await_d = yield d;
|
||||
let await_e = yield e;
|
||||
});
|
||||
}
|
||||
39
tests/baselines/reference/awaitUnion_es6.symbols
Normal file
39
tests/baselines/reference/awaitUnion_es6.symbols
Normal file
@@ -0,0 +1,39 @@
|
||||
=== tests/cases/conformance/async/es6/awaitUnion_es6.ts ===
|
||||
declare let a: number | string;
|
||||
>a : Symbol(a, Decl(awaitUnion_es6.ts, 0, 11))
|
||||
|
||||
declare let b: PromiseLike<number> | PromiseLike<string>;
|
||||
>b : Symbol(b, Decl(awaitUnion_es6.ts, 1, 11))
|
||||
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163))
|
||||
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163))
|
||||
|
||||
declare let c: PromiseLike<number | string>;
|
||||
>c : Symbol(c, Decl(awaitUnion_es6.ts, 2, 11))
|
||||
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163))
|
||||
|
||||
declare let d: number | PromiseLike<string>;
|
||||
>d : Symbol(d, Decl(awaitUnion_es6.ts, 3, 11))
|
||||
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163))
|
||||
|
||||
declare let e: number | PromiseLike<number | string>;
|
||||
>e : Symbol(e, Decl(awaitUnion_es6.ts, 4, 11))
|
||||
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163))
|
||||
|
||||
async function f() {
|
||||
>f : Symbol(f, Decl(awaitUnion_es6.ts, 4, 53))
|
||||
|
||||
let await_a = await a;
|
||||
>await_a : Symbol(await_a, Decl(awaitUnion_es6.ts, 6, 4))
|
||||
|
||||
let await_b = await b;
|
||||
>await_b : Symbol(await_b, Decl(awaitUnion_es6.ts, 7, 4))
|
||||
|
||||
let await_c = await c;
|
||||
>await_c : Symbol(await_c, Decl(awaitUnion_es6.ts, 8, 4))
|
||||
|
||||
let await_d = await d;
|
||||
>await_d : Symbol(await_d, Decl(awaitUnion_es6.ts, 9, 4))
|
||||
|
||||
let await_e = await e;
|
||||
>await_e : Symbol(await_e, Decl(awaitUnion_es6.ts, 10, 4))
|
||||
}
|
||||
44
tests/baselines/reference/awaitUnion_es6.types
Normal file
44
tests/baselines/reference/awaitUnion_es6.types
Normal file
@@ -0,0 +1,44 @@
|
||||
=== tests/cases/conformance/async/es6/awaitUnion_es6.ts ===
|
||||
declare let a: number | string;
|
||||
>a : string | number
|
||||
|
||||
declare let b: PromiseLike<number> | PromiseLike<string>;
|
||||
>b : PromiseLike<number> | PromiseLike<string>
|
||||
>PromiseLike : PromiseLike<T>
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
declare let c: PromiseLike<number | string>;
|
||||
>c : PromiseLike<string | number>
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
declare let d: number | PromiseLike<string>;
|
||||
>d : number | PromiseLike<string>
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
declare let e: number | PromiseLike<number | string>;
|
||||
>e : number | PromiseLike<string | number>
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
async function f() {
|
||||
>f : () => Promise<void>
|
||||
|
||||
let await_a = await a;
|
||||
>await_a : string | number
|
||||
>a : any
|
||||
|
||||
let await_b = await b;
|
||||
>await_b : string | number
|
||||
>b : any
|
||||
|
||||
let await_c = await c;
|
||||
>await_c : string | number
|
||||
>c : any
|
||||
|
||||
let await_d = await d;
|
||||
>await_d : string | number
|
||||
>d : any
|
||||
|
||||
let await_e = await e;
|
||||
>await_e : string | number
|
||||
>e : any
|
||||
}
|
||||
14
tests/cases/conformance/async/es6/awaitUnion_es6.ts
Normal file
14
tests/cases/conformance/async/es6/awaitUnion_es6.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
// @target: ES6
|
||||
// @noEmitHelpers: true
|
||||
declare let a: number | string;
|
||||
declare let b: PromiseLike<number> | PromiseLike<string>;
|
||||
declare let c: PromiseLike<number | string>;
|
||||
declare let d: number | PromiseLike<string>;
|
||||
declare let e: number | PromiseLike<number | string>;
|
||||
async function f() {
|
||||
let await_a = await a;
|
||||
let await_b = await b;
|
||||
let await_c = await c;
|
||||
let await_d = await d;
|
||||
let await_e = await e;
|
||||
}
|
||||
Reference in New Issue
Block a user