Skip to content

Commit 5b1a139

Browse files
committed
Add tests
1 parent 0c905ae commit 5b1a139

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

Diff for: tests/baselines/reference/promiseType.js

+6
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ 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+
(undefined as Promise<any>).then(undefined as () => Promise<number> | string);
220224

221225

222226
//// [promiseType.js]
@@ -440,3 +444,5 @@ const pc6 = p.then(() => Promise.reject("1"), () => { });
440444
const pc7 = p.then(() => Promise.reject("1"), () => { throw 1; });
441445
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
442446
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
447+
// #30390
448+
undefined.then(undefined);

Diff for: tests/baselines/reference/promiseType.symbols

+10
Original file line numberDiff line numberDiff line change
@@ -1089,3 +1089,13 @@ 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+
(undefined as Promise<any>).then(undefined as () => Promise<number> | string);
1095+
>(undefined as Promise<any>).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
1096+
>undefined : Symbol(undefined)
1097+
>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, --, --))
1098+
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
1099+
>undefined : Symbol(undefined)
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+

Diff for: 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+
(undefined as Promise<any>).then(undefined as () => Promise<number> | string);
1589+
>(undefined as Promise<any>).then(undefined as () => Promise<number> | string) : Promise<string | number>
1590+
>(undefined as Promise<any>).then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<(TResult1 extends PromiseLike<infer UResult1> ? UResult1 : TResult1) | (TResult2 extends PromiseLike<infer UResult2> ? UResult2 : TResult2)>
1591+
>(undefined as Promise<any>) : Promise<any>
1592+
>undefined as Promise<any> : Promise<any>
1593+
>undefined : undefined
1594+
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<(TResult1 extends PromiseLike<infer UResult1> ? UResult1 : TResult1) | (TResult2 extends PromiseLike<infer UResult2> ? UResult2 : TResult2)>
1595+
>undefined as () => Promise<number> | string : () => string | Promise<number>
1596+
>undefined : undefined
1597+

Diff for: tests/cases/compiler/promiseType.ts

+4
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,7 @@ 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+
(undefined as Promise<any>).then(undefined as () => Promise<number> | string);

0 commit comments

Comments
 (0)