Skip to content

Commit c0fdc66

Browse files
committed
Add tests
1 parent 6509e54 commit c0fdc66

File tree

4 files changed

+136
-0
lines changed

4 files changed

+136
-0
lines changed

tests/baselines/reference/promiseType.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,26 @@ const pc6 = p.then(() => Promise.reject("1"), () => {});
217217
const pc7 = p.then(() => Promise.reject("1"), () => {throw 1});
218218
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
219219
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
220+
221+
declare const x2: Promise<number> | string;
222+
223+
// #28427
224+
225+
Promise.all([x2]);
226+
227+
// #33074
228+
229+
Promise.resolve(x2);
230+
231+
// #30390
232+
233+
declare function f1(): Promise<number> | string;
234+
p.then(f1);
235+
236+
// #33062
237+
238+
declare function f2(resolve: (value: Promise<number> | string) => void);
239+
new Promise(f2);
220240

221241

222242
//// [promiseType.js]
@@ -440,3 +460,9 @@ const pc6 = p.then(() => Promise.reject("1"), () => { });
440460
const pc7 = p.then(() => Promise.reject("1"), () => { throw 1; });
441461
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
442462
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
463+
// #28427
464+
Promise.all([x2]);
465+
// #33074
466+
Promise.resolve(x2);
467+
p.then(f1);
468+
new Promise(f2);

tests/baselines/reference/promiseType.symbols

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,3 +1089,47 @@ const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
10891089
>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, --, --))
10901090
>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --))
10911091

1092+
declare const x2: Promise<number> | string;
1093+
>x2 : Symbol(x2, Decl(promiseType.ts, 219, 13))
1094+
>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, --, --))
1095+
1096+
// #28427
1097+
1098+
Promise.all([x2]);
1099+
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --) ... and 6 more)
1100+
>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, --, --))
1101+
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --) ... and 6 more)
1102+
>x2 : Symbol(x2, Decl(promiseType.ts, 219, 13))
1103+
1104+
// #33074
1105+
1106+
Promise.resolve(x2);
1107+
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
1108+
>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, --, --))
1109+
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
1110+
>x2 : Symbol(x2, Decl(promiseType.ts, 219, 13))
1111+
1112+
// #30390
1113+
1114+
declare function f1(): Promise<number> | string;
1115+
>f1 : Symbol(f1, Decl(promiseType.ts, 227, 20))
1116+
>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, --, --))
1117+
1118+
p.then(f1);
1119+
>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
1120+
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
1121+
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
1122+
>f1 : Symbol(f1, Decl(promiseType.ts, 227, 20))
1123+
1124+
// #33062
1125+
1126+
declare function f2(resolve: (value: Promise<number> | string) => void);
1127+
>f2 : Symbol(f2, Decl(promiseType.ts, 232, 11))
1128+
>resolve : Symbol(resolve, Decl(promiseType.ts, 236, 20))
1129+
>value : Symbol(value, Decl(promiseType.ts, 236, 30))
1130+
>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, --, --))
1131+
1132+
new Promise(f2);
1133+
>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, --, --))
1134+
>f2 : Symbol(f2, Decl(promiseType.ts, 232, 11))
1135+

tests/baselines/reference/promiseType.types

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,3 +1583,49 @@ const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
15831583
>reject : <T = never>(reason?: any) => Promise<T>
15841584
>1 : 1
15851585

1586+
declare const x2: Promise<number> | string;
1587+
>x2 : string | Promise<number>
1588+
1589+
// #28427
1590+
1591+
Promise.all([x2]);
1592+
>Promise.all([x2]) : Promise<(string | number)[]>
1593+
>Promise.all : { <TAll>(values: Iterable<TAll>): Promise<(TAll extends PromiseLike<infer UAll> ? UAll : TAll)[]>; <T extends readonly [any, any, any, any, any, any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any, any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly any[]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; }
1594+
>Promise : PromiseConstructor
1595+
>all : { <TAll>(values: Iterable<TAll>): Promise<(TAll extends PromiseLike<infer UAll> ? UAll : TAll)[]>; <T extends readonly [any, any, any, any, any, any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any, any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly [any, any]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; <T extends readonly any[]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; }
1596+
>[x2] : (string | Promise<number>)[]
1597+
>x2 : string | Promise<number>
1598+
1599+
// #33074
1600+
1601+
Promise.resolve(x2);
1602+
>Promise.resolve(x2) : Promise<string | number>
1603+
>Promise.resolve : { <T>(value: T): Promise<Awaited<T>>; (): Promise<void>; }
1604+
>Promise : PromiseConstructor
1605+
>resolve : { <T>(value: T): Promise<Awaited<T>>; (): Promise<void>; }
1606+
>x2 : string | Promise<number>
1607+
1608+
// #30390
1609+
1610+
declare function f1(): Promise<number> | string;
1611+
>f1 : () => string | Promise<number>
1612+
1613+
p.then(f1);
1614+
>p.then(f1) : Promise<string | number>
1615+
>p.then : <TResult1 = boolean, TResult2 = never>(onfulfilled?: (value: boolean) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<(TResult1 extends PromiseLike<infer UResult1> ? UResult1 : TResult1) | (TResult2 extends PromiseLike<infer UResult2> ? UResult2 : TResult2)>
1616+
>p : Promise<boolean>
1617+
>then : <TResult1 = boolean, TResult2 = never>(onfulfilled?: (value: boolean) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<(TResult1 extends PromiseLike<infer UResult1> ? UResult1 : TResult1) | (TResult2 extends PromiseLike<infer UResult2> ? UResult2 : TResult2)>
1618+
>f1 : () => string | Promise<number>
1619+
1620+
// #33062
1621+
1622+
declare function f2(resolve: (value: Promise<number> | string) => void);
1623+
>f2 : (resolve: (value: string | Promise<number>) => void) => any
1624+
>resolve : (value: string | Promise<number>) => void
1625+
>value : string | Promise<number>
1626+
1627+
new Promise(f2);
1628+
>new Promise(f2) : Promise<string | number>
1629+
>Promise : PromiseConstructor
1630+
>f2 : (resolve: (value: string | Promise<number>) => void) => any
1631+

tests/cases/compiler/promiseType.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,23 @@ const pc6 = p.then(() => Promise.reject("1"), () => {});
217217
const pc7 = p.then(() => Promise.reject("1"), () => {throw 1});
218218
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
219219
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
220+
221+
declare const x2: Promise<number> | string;
222+
223+
// #28427
224+
225+
Promise.all([x2]);
226+
227+
// #33074
228+
229+
Promise.resolve(x2);
230+
231+
// #30390
232+
233+
declare function f1(): Promise<number> | string;
234+
p.then(f1);
235+
236+
// #33062
237+
238+
declare function f2(resolve: (value: Promise<number> | string) => void);
239+
new Promise(f2);

0 commit comments

Comments
 (0)