Skip to content

Commit 1abb98b

Browse files
committed
Add tests
1 parent c55f4f4 commit 1abb98b

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

tests/baselines/reference/promiseType.js

+6
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ 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+
// #30390
222+
223+
declare function f(): Promise<number> | string;
224+
p.then(f);
220225

221226

222227
//// [promiseType.js]
@@ -440,3 +445,4 @@ const pc6 = p.then(() => Promise.reject("1"), () => { });
440445
const pc7 = p.then(() => Promise.reject("1"), () => { throw 1; });
441446
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
442447
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
448+
p.then(f);

tests/baselines/reference/promiseType.symbols

+12
Original file line numberDiff line numberDiff line change
@@ -1089,3 +1089,15 @@ 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+
// #30390
1093+
1094+
declare function f(): Promise<number> | string;
1095+
>f : Symbol(f, Decl(promiseType.ts, 217, 71))
1096+
>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, --, --))
1097+
1098+
p.then(f);
1099+
>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
1100+
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
1101+
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
1102+
>f : Symbol(f, Decl(promiseType.ts, 217, 71))
1103+

tests/baselines/reference/promiseType.types

+12
Original file line numberDiff line numberDiff line change
@@ -1583,3 +1583,15 @@ const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
15831583
>reject : <T = never>(reason?: any) => Promise<T>
15841584
>1 : 1
15851585

1586+
// #30390
1587+
1588+
declare function f(): Promise<number> | string;
1589+
>f : () => string | Promise<number>
1590+
1591+
p.then(f);
1592+
>p.then(f) : Promise<string | number>
1593+
>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)>
1594+
>p : Promise<boolean>
1595+
>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)>
1596+
>f : () => string | Promise<number>
1597+

tests/cases/compiler/promiseType.ts

+5
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,8 @@ 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+
// #30390
222+
223+
declare function f(): Promise<number> | string;
224+
p.then(f);

0 commit comments

Comments
 (0)