From 6798944ca49869b42d2b2ee108c6a8d473ff68f3 Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Thu, 29 Aug 2019 09:59:41 -0700 Subject: [PATCH] Add tests --- tests/baselines/reference/promiseType.js | 6 ++++++ tests/baselines/reference/promiseType.symbols | 12 ++++++++++++ tests/baselines/reference/promiseType.types | 13 +++++++++++++ tests/cases/compiler/promiseType.ts | 5 +++++ 4 files changed, 36 insertions(+) diff --git a/tests/baselines/reference/promiseType.js b/tests/baselines/reference/promiseType.js index 84d9d713b4810..d7ed170b65683 100644 --- a/tests/baselines/reference/promiseType.js +++ b/tests/baselines/reference/promiseType.js @@ -217,6 +217,11 @@ const pc6 = p.then(() => Promise.reject("1"), () => {}); const pc7 = p.then(() => Promise.reject("1"), () => {throw 1}); const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); + +// #28427 + +declare const x2: Promise | string; +Promise.all([x2]); //// [promiseType.js] @@ -440,3 +445,4 @@ const pc6 = p.then(() => Promise.reject("1"), () => { }); const pc7 = p.then(() => Promise.reject("1"), () => { throw 1; }); const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); +Promise.all([x2]); diff --git a/tests/baselines/reference/promiseType.symbols b/tests/baselines/reference/promiseType.symbols index cec81cd7d8266..074c35d24c360 100644 --- a/tests/baselines/reference/promiseType.symbols +++ b/tests/baselines/reference/promiseType.symbols @@ -1089,3 +1089,15 @@ const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); >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, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --)) +// #28427 + +declare const x2: Promise | string; +>x2 : Symbol(x2, Decl(promiseType.ts, 221, 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, --, --)) + +Promise.all([x2]); +>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>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, --, --)) +>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>x2 : Symbol(x2, Decl(promiseType.ts, 221, 13)) + diff --git a/tests/baselines/reference/promiseType.types b/tests/baselines/reference/promiseType.types index dd20fb656ea5a..32f667f63f4a2 100644 --- a/tests/baselines/reference/promiseType.types +++ b/tests/baselines/reference/promiseType.types @@ -1583,3 +1583,16 @@ const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); >reject : (reason?: any) => Promise >1 : 1 +// #28427 + +declare const x2: Promise | string; +>x2 : string | Promise + +Promise.all([x2]); +>Promise.all([x2]) : Promise<(string | number)[]> +>Promise.all : { (values: Iterable): Promise<(TAll extends PromiseLike ? UAll : TAll)[]>; (values: T): Promise<{ -readonly [P in keyof T]: PromisedType; }>; } +>Promise : PromiseConstructor +>all : { (values: Iterable): Promise<(TAll extends PromiseLike ? UAll : TAll)[]>; (values: T): Promise<{ -readonly [P in keyof T]: PromisedType; }>; } +>[x2] : (string | Promise)[] +>x2 : string | Promise + diff --git a/tests/cases/compiler/promiseType.ts b/tests/cases/compiler/promiseType.ts index ba4a7f6041396..03791d259a00c 100644 --- a/tests/cases/compiler/promiseType.ts +++ b/tests/cases/compiler/promiseType.ts @@ -217,3 +217,8 @@ const pc6 = p.then(() => Promise.reject("1"), () => {}); const pc7 = p.then(() => Promise.reject("1"), () => {throw 1}); const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); + +// #28427 + +declare const x2: Promise | string; +Promise.all([x2]);