diff --git a/src/lib/es2015.promise.d.ts b/src/lib/es2015.promise.d.ts index 45b0fa5dc59d9..30dccdf3ca357 100644 --- a/src/lib/es2015.promise.d.ts +++ b/src/lib/es2015.promise.d.ts @@ -120,7 +120,7 @@ interface PromiseConstructor { * @param value A promise. * @returns A promise whose internal state matches the provided promise. */ - resolve(value: T | PromiseLike): Promise; + resolve(value: T): Promise ? U : T>; /** * Creates a new resolved promise . diff --git a/tests/baselines/reference/asyncArrowFunction11_es5.types b/tests/baselines/reference/asyncArrowFunction11_es5.types index 7fd9d53af7228..a22b85f084bfa 100644 --- a/tests/baselines/reference/asyncArrowFunction11_es5.types +++ b/tests/baselines/reference/asyncArrowFunction11_es5.types @@ -11,9 +11,9 @@ class A { await Promise.resolve(); >await Promise.resolve() : void >Promise.resolve() : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } const obj = { ["a"]: () => this }; // computed property name after `await` triggers case >obj : { a: () => this; } diff --git a/tests/baselines/reference/asyncFunctionReturnType.js b/tests/baselines/reference/asyncFunctionReturnType.js index 04b3a04a036d3..30826de671fe7 100644 --- a/tests/baselines/reference/asyncFunctionReturnType.js +++ b/tests/baselines/reference/asyncFunctionReturnType.js @@ -67,13 +67,14 @@ async function fGenericIndexedTypeForKProp(obj: TObj, key: K): Promise { +async function fGenericIndexedTypeForPromiseOfKProp(obj: TObj, key: K): Promise ? U : TObj[K]> { return Promise.resolve(obj[key]); } -async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise { +async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise ? U : TObj[K]> { return Promise.resolve(obj[key]); -} +} + //// [asyncFunctionReturnType.js] var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { diff --git a/tests/baselines/reference/asyncFunctionReturnType.symbols b/tests/baselines/reference/asyncFunctionReturnType.symbols index 25a7e944c6a7a..f954b79555bf9 100644 --- a/tests/baselines/reference/asyncFunctionReturnType.symbols +++ b/tests/baselines/reference/asyncFunctionReturnType.symbols @@ -240,7 +240,7 @@ async function fGenericIndexedTypeForKPropkey : Symbol(key, Decl(asyncFunctionReturnType.ts, 64, 93)) } -async function fGenericIndexedTypeForPromiseOfKProp(obj: TObj, key: K): Promise { +async function fGenericIndexedTypeForPromiseOfKProp(obj: TObj, key: K): Promise ? U : TObj[K]> { >fGenericIndexedTypeForPromiseOfKProp : Symbol(fGenericIndexedTypeForPromiseOfKProp, Decl(asyncFunctionReturnType.ts, 66, 1)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) @@ -252,6 +252,11 @@ async function fGenericIndexedTypeForPromiseOfKPropK : Symbol(K, Decl(asyncFunctionReturnType.ts, 68, 69)) >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, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 68, 69)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) +>U : Symbol(U, Decl(asyncFunctionReturnType.ts, 68, 153)) +>U : Symbol(U, Decl(asyncFunctionReturnType.ts, 68, 153)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52)) >K : Symbol(K, Decl(asyncFunctionReturnType.ts, 68, 69)) return Promise.resolve(obj[key]); @@ -262,7 +267,7 @@ async function fGenericIndexedTypeForPromiseOfKPropkey : Symbol(key, Decl(asyncFunctionReturnType.ts, 68, 102)) } -async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise { +async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise ? U : TObj[K]> { >fGenericIndexedTypeForExplicitPromiseOfKProp : Symbol(fGenericIndexedTypeForExplicitPromiseOfKProp, Decl(asyncFunctionReturnType.ts, 70, 1)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) @@ -274,6 +279,11 @@ async function fGenericIndexedTypeForExplicitPromiseOfKPropK : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77)) >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, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60)) +>K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) +>U : Symbol(U, Decl(asyncFunctionReturnType.ts, 72, 161)) +>U : Symbol(U, Decl(asyncFunctionReturnType.ts, 72, 161)) +>TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60)) >K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77)) return Promise.resolve(obj[key]); @@ -285,3 +295,4 @@ async function fGenericIndexedTypeForExplicitPromiseOfKPropobj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 72, 100)) >key : Symbol(key, Decl(asyncFunctionReturnType.ts, 72, 110)) } + diff --git a/tests/baselines/reference/asyncFunctionReturnType.types b/tests/baselines/reference/asyncFunctionReturnType.types index d2cb63e0a35f3..80c8d5bf1cfdd 100644 --- a/tests/baselines/reference/asyncFunctionReturnType.types +++ b/tests/baselines/reference/asyncFunctionReturnType.types @@ -44,9 +44,9 @@ async function fIndexedTypeForPromiseOfStringProp(obj: Obj): PromisePromise.resolve(obj.stringProp) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >obj.stringProp : string >obj : Obj >stringProp : string @@ -58,9 +58,9 @@ async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise(obj.stringProp); >Promise.resolve(obj.stringProp) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >obj.stringProp : string >obj : Obj >stringProp : string @@ -82,9 +82,9 @@ async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): PromisePromise.resolve(obj.anyProp) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >obj.anyProp : any >obj : Obj >anyProp : any @@ -96,9 +96,9 @@ async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise(obj.anyProp); >Promise.resolve(obj.anyProp) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >obj.anyProp : any >obj : Obj >anyProp : any @@ -120,9 +120,9 @@ async function fGenericIndexedTypeForPromiseOfStringProp(obj: return Promise.resolve(obj.stringProp); >Promise.resolve(obj.stringProp) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >obj.stringProp : string >obj : TObj >stringProp : string @@ -133,10 +133,10 @@ async function fGenericIndexedTypeForExplicitPromiseOfStringPropobj : TObj return Promise.resolve(obj.stringProp); ->Promise.resolve(obj.stringProp) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve(obj.stringProp) : Promise ? U : TObj["stringProp"]> +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >obj.stringProp : string >obj : TObj >stringProp : string @@ -158,9 +158,9 @@ async function fGenericIndexedTypeForPromiseOfAnyProp(obj: TOb return Promise.resolve(obj.anyProp); >Promise.resolve(obj.anyProp) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >obj.anyProp : any >obj : TObj >anyProp : any @@ -171,10 +171,10 @@ async function fGenericIndexedTypeForExplicitPromiseOfAnyProp( >obj : TObj return Promise.resolve(obj.anyProp); ->Promise.resolve(obj.anyProp) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve(obj.anyProp) : Promise ? U : TObj["anyProp"]> +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >obj.anyProp : any >obj : TObj >anyProp : any @@ -191,32 +191,33 @@ async function fGenericIndexedTypeForKPropkey : K } -async function fGenericIndexedTypeForPromiseOfKProp(obj: TObj, key: K): Promise { ->fGenericIndexedTypeForPromiseOfKProp : (obj: TObj, key: K) => Promise +async function fGenericIndexedTypeForPromiseOfKProp(obj: TObj, key: K): Promise ? U : TObj[K]> { +>fGenericIndexedTypeForPromiseOfKProp : (obj: TObj, key: K) => Promise ? U : TObj[K]> >obj : TObj >key : K return Promise.resolve(obj[key]); ->Promise.resolve(obj[key]) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve(obj[key]) : Promise ? U : TObj[K]> +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >obj[key] : TObj[K] >obj : TObj >key : K } -async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise { ->fGenericIndexedTypeForExplicitPromiseOfKProp : (obj: TObj, key: K) => Promise +async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise ? U : TObj[K]> { +>fGenericIndexedTypeForExplicitPromiseOfKProp : (obj: TObj, key: K) => Promise ? U : TObj[K]> >obj : TObj >key : K return Promise.resolve(obj[key]); ->Promise.resolve(obj[key]) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve(obj[key]) : Promise ? U : TObj[K]> +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >obj[key] : TObj[K] >obj : TObj >key : K } + diff --git a/tests/baselines/reference/exportDefaultAsyncFunction2.types b/tests/baselines/reference/exportDefaultAsyncFunction2.types index 0e6ad89ccdfe6..cc0a0fb403870 100644 --- a/tests/baselines/reference/exportDefaultAsyncFunction2.types +++ b/tests/baselines/reference/exportDefaultAsyncFunction2.types @@ -19,9 +19,9 @@ export default async(() => await(Promise.resolve(1))); >await(Promise.resolve(1)) : any >await : (...args: any[]) => any >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 === tests/cases/compiler/b.ts === diff --git a/tests/baselines/reference/genericFunctionInference1.types b/tests/baselines/reference/genericFunctionInference1.types index 1974fe17bea80..c2d2c52542e07 100644 --- a/tests/baselines/reference/genericFunctionInference1.types +++ b/tests/baselines/reference/genericFunctionInference1.types @@ -835,9 +835,9 @@ const fn30: Fn = pipe( const promise = Promise.resolve(1); >promise : Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 promise.then( diff --git a/tests/baselines/reference/inferFromGenericFunctionReturnTypes3.types b/tests/baselines/reference/inferFromGenericFunctionReturnTypes3.types index f9192dd11baad..d9a89f375dd90 100644 --- a/tests/baselines/reference/inferFromGenericFunctionReturnTypes3.types +++ b/tests/baselines/reference/inferFromGenericFunctionReturnTypes3.types @@ -7,9 +7,9 @@ function truePromise(): Promise { return Promise.resolve(true); >Promise.resolve(true) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >true : true } diff --git a/tests/baselines/reference/instantiateContextualTypes.types b/tests/baselines/reference/instantiateContextualTypes.types index b5317b6f7561f..48f4d8ab8c00f 100644 --- a/tests/baselines/reference/instantiateContextualTypes.types +++ b/tests/baselines/reference/instantiateContextualTypes.types @@ -342,9 +342,9 @@ class Interesting { >Promise.resolve().then(() => { if (1 < 2) { return 'SOMETHING'; } return 'ELSE'; }) : Promise >Promise.resolve().then : (onfulfilled?: ((value: void) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >Promise.resolve() : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >then : (onfulfilled?: ((value: void) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => { if (1 < 2) { return 'SOMETHING'; } return 'ELSE'; } : () => "SOMETHING" | "ELSE" @@ -369,9 +369,9 @@ class Interesting { >Promise.resolve().then(() => { return 'ELSE'; }) : Promise >Promise.resolve().then : (onfulfilled?: ((value: void) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >Promise.resolve() : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >then : (onfulfilled?: ((value: void) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => { return 'ELSE'; } : () => "ELSE" @@ -388,9 +388,9 @@ class Interesting { >Promise.resolve().then(() => { if (1 < 2) { return 'SOMETHING'; } return 'SOMETHING'; }) : Promise >Promise.resolve().then : (onfulfilled?: ((value: void) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >Promise.resolve() : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >then : (onfulfilled?: ((value: void) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => { if (1 < 2) { return 'SOMETHING'; } return 'SOMETHING'; } : () => "SOMETHING" diff --git a/tests/baselines/reference/jsdocArrayObjectPromiseImplicitAny.types b/tests/baselines/reference/jsdocArrayObjectPromiseImplicitAny.types index 3fab5033c2305..1c23dee8acfd9 100644 --- a/tests/baselines/reference/jsdocArrayObjectPromiseImplicitAny.types +++ b/tests/baselines/reference/jsdocArrayObjectPromiseImplicitAny.types @@ -27,18 +27,18 @@ function returnAnyArray(arr) { var anyPromise = Promise.resolve(5); >anyPromise : Promise >Promise.resolve(5) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >5 : 5 /** @type {Promise} */ var numberPromise = Promise.resolve(5); >numberPromise : Promise >Promise.resolve(5) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >5 : 5 /** diff --git a/tests/baselines/reference/jsdocArrayObjectPromiseNoImplicitAny.types b/tests/baselines/reference/jsdocArrayObjectPromiseNoImplicitAny.types index 82ff886f1ec68..7d5891d6309f1 100644 --- a/tests/baselines/reference/jsdocArrayObjectPromiseNoImplicitAny.types +++ b/tests/baselines/reference/jsdocArrayObjectPromiseNoImplicitAny.types @@ -27,18 +27,18 @@ function returnNotAnyArray(arr) { var notAnyPromise = Promise.resolve(5); >notAnyPromise : Promise >Promise.resolve(5) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >5 : 5 /** @type {Promise} */ var numberPromise = Promise.resolve(5); >numberPromise : Promise >Promise.resolve(5) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >5 : 5 /** diff --git a/tests/baselines/reference/noImplicitReturnsInAsync1.types b/tests/baselines/reference/noImplicitReturnsInAsync1.types index dd468d33e6e21..89f3ed5c6036b 100644 --- a/tests/baselines/reference/noImplicitReturnsInAsync1.types +++ b/tests/baselines/reference/noImplicitReturnsInAsync1.types @@ -15,8 +15,8 @@ async function test(isError: boolean = false) { >x : string >await Promise.resolve("The test is passed without an error.") : string >Promise.resolve("The test is passed without an error.") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"The test is passed without an error." : "The test is passed without an error." } diff --git a/tests/baselines/reference/promiseType.types b/tests/baselines/reference/promiseType.types index dd20fb656ea5a..347885d24a193 100644 --- a/tests/baselines/reference/promiseType.types +++ b/tests/baselines/reference/promiseType.types @@ -283,9 +283,9 @@ const p19 = p.catch(() => Promise.resolve(1)); >catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p20 = p.then(undefined); @@ -365,9 +365,9 @@ const p28 = p.then(() => Promise.resolve(1)); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p29 = p.then(() => Promise.reject(1)); @@ -469,9 +469,9 @@ const p38 = p.then(undefined, () => Promise.resolve(1)); >undefined : undefined >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p39 = p.then(undefined, () => Promise.reject(1)); @@ -574,9 +574,9 @@ const p48 = p.then(null, () => Promise.resolve(1)); >null : null >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p49 = p.then(null, () => Promise.reject(1)); @@ -688,9 +688,9 @@ const p58 = p.then(() => "1", () => Promise.resolve(1)); >"1" : "1" >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p59 = p.then(() => "1", () => Promise.reject(1)); @@ -803,9 +803,9 @@ const p68 = p.then(() => x, () => Promise.resolve(1)); >x : any >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p69 = p.then(() => x, () => Promise.reject(1)); @@ -918,9 +918,9 @@ const p78 = p.then(() => undefined, () => Promise.resolve(1)); >undefined : undefined >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p79 = p.then(() => undefined, () => Promise.reject(1)); @@ -1033,9 +1033,9 @@ const p88 = p.then(() => null, () => Promise.resolve(1)); >null : null >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p89 = p.then(() => null, () => Promise.reject(1)); @@ -1139,9 +1139,9 @@ const p98 = p.then(() => {}, () => Promise.resolve(1)); >() => {} : () => void >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p99 = p.then(() => {}, () => Promise.reject(1)); @@ -1253,9 +1253,9 @@ const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1)); >1 : 1 >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const pa9 = p.then(() => {throw 1}, () => Promise.reject(1)); @@ -1281,9 +1281,9 @@ const pb0 = p.then(() => Promise.resolve("1"), undefined); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >undefined : undefined @@ -1295,9 +1295,9 @@ const pb1 = p.then(() => Promise.resolve("1"), null); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >null : null @@ -1309,9 +1309,9 @@ const pb2 = p.then(() => Promise.resolve("1"), () => 1); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => 1 : () => number >1 : 1 @@ -1324,9 +1324,9 @@ const pb3 = p.then(() => Promise.resolve("1"), () => x); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => x : () => any >x : any @@ -1339,9 +1339,9 @@ const pb4 = p.then(() => Promise.resolve("1"), () => undefined); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => undefined : () => any >undefined : undefined @@ -1354,9 +1354,9 @@ const pb5 = p.then(() => Promise.resolve("1"), () => null); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => null : () => any >null : null @@ -1369,9 +1369,9 @@ const pb6 = p.then(() => Promise.resolve("1"), () => {}); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => {} : () => void @@ -1383,9 +1383,9 @@ const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1}); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => {throw 1} : () => never >1 : 1 @@ -1398,15 +1398,15 @@ const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); @@ -1417,9 +1417,9 @@ const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise @@ -1559,9 +1559,9 @@ const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); >"1" : "1" >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); diff --git a/tests/baselines/reference/promiseTypeStrictNull.types b/tests/baselines/reference/promiseTypeStrictNull.types index 73d2f70346135..f78ea1eb4822e 100644 --- a/tests/baselines/reference/promiseTypeStrictNull.types +++ b/tests/baselines/reference/promiseTypeStrictNull.types @@ -283,9 +283,9 @@ const p19 = p.catch(() => Promise.resolve(1)); >catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p20 = p.then(undefined); @@ -365,9 +365,9 @@ const p28 = p.then(() => Promise.resolve(1)); >then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p29 = p.then(() => Promise.reject(1)); @@ -469,9 +469,9 @@ const p38 = p.then(undefined, () => Promise.resolve(1)); >undefined : undefined >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p39 = p.then(undefined, () => Promise.reject(1)); @@ -574,9 +574,9 @@ const p48 = p.then(null, () => Promise.resolve(1)); >null : null >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p49 = p.then(null, () => Promise.reject(1)); @@ -688,9 +688,9 @@ const p58 = p.then(() => "1", () => Promise.resolve(1)); >"1" : "1" >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p59 = p.then(() => "1", () => Promise.reject(1)); @@ -803,9 +803,9 @@ const p68 = p.then(() => x, () => Promise.resolve(1)); >x : any >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p69 = p.then(() => x, () => Promise.reject(1)); @@ -918,9 +918,9 @@ const p78 = p.then(() => undefined, () => Promise.resolve(1)); >undefined : undefined >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p79 = p.then(() => undefined, () => Promise.reject(1)); @@ -1033,9 +1033,9 @@ const p88 = p.then(() => null, () => Promise.resolve(1)); >null : null >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p89 = p.then(() => null, () => Promise.reject(1)); @@ -1139,9 +1139,9 @@ const p98 = p.then(() => {}, () => Promise.resolve(1)); >() => {} : () => void >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const p99 = p.then(() => {}, () => Promise.reject(1)); @@ -1253,9 +1253,9 @@ const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1)); >1 : 1 >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const pa9 = p.then(() => {throw 1}, () => Promise.reject(1)); @@ -1281,9 +1281,9 @@ const pb0 = p.then(() => Promise.resolve("1"), undefined); >then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >undefined : undefined @@ -1295,9 +1295,9 @@ const pb1 = p.then(() => Promise.resolve("1"), null); >then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >null : null @@ -1309,9 +1309,9 @@ const pb2 = p.then(() => Promise.resolve("1"), () => 1); >then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => 1 : () => number >1 : 1 @@ -1324,9 +1324,9 @@ const pb3 = p.then(() => Promise.resolve("1"), () => x); >then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => x : () => any >x : any @@ -1339,9 +1339,9 @@ const pb4 = p.then(() => Promise.resolve("1"), () => undefined); >then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => undefined : () => undefined >undefined : undefined @@ -1354,9 +1354,9 @@ const pb5 = p.then(() => Promise.resolve("1"), () => null); >then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => null : () => null >null : null @@ -1369,9 +1369,9 @@ const pb6 = p.then(() => Promise.resolve("1"), () => {}); >then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => {} : () => void @@ -1383,9 +1383,9 @@ const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1}); >then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => {throw 1} : () => never >1 : 1 @@ -1398,15 +1398,15 @@ const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); >then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); @@ -1417,9 +1417,9 @@ const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); >then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >"1" : "1" >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise @@ -1559,9 +1559,9 @@ const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); >"1" : "1" >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); diff --git a/tests/baselines/reference/promiseVoidErrorCallback.types b/tests/baselines/reference/promiseVoidErrorCallback.types index a1388cb04ef69..945a06e0c6e62 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.types +++ b/tests/baselines/reference/promiseVoidErrorCallback.types @@ -19,9 +19,9 @@ function f1(): Promise { return Promise.resolve({ __t1: "foo_t1" }); >Promise.resolve({ __t1: "foo_t1" }) : Promise<{ __t1: string; }> ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >{ __t1: "foo_t1" } : { __t1: string; } >__t1 : string >"foo_t1" : "foo_t1" diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.types b/tests/baselines/reference/transformNestedGeneratorsWithTry.types index 061342eaf44b0..72db86e5e90f2 100644 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.types +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.types @@ -16,9 +16,9 @@ async function a(): Bluebird { await Bluebird.resolve(); // -- remove this and it compiles >await Bluebird.resolve() : void >Bluebird.resolve() : Promise ->Bluebird.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Bluebird.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Bluebird : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } } catch (error) { } >error : any diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.1.types b/tests/baselines/reference/types.asyncGenerators.es2018.1.types index 3c6e51c56d220..b6bead32e7f28 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.1.types +++ b/tests/baselines/reference/types.asyncGenerators.es2018.1.types @@ -21,9 +21,9 @@ async function * inferReturnType4() { yield Promise.resolve(1); >yield Promise.resolve(1) : any >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 } async function * inferReturnType5() { @@ -36,9 +36,9 @@ async function * inferReturnType5() { yield Promise.resolve(2); >yield Promise.resolve(2) : any >Promise.resolve(2) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >2 : 2 } async function * inferReturnType6() { @@ -57,9 +57,9 @@ async function * inferReturnType7() { >yield* [Promise.resolve(1)] : any >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 } async function * inferReturnType8() { @@ -89,9 +89,9 @@ const assignability2: () => AsyncIterableIterator = async function * () yield Promise.resolve(1); >yield Promise.resolve(1) : undefined >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 }; @@ -114,9 +114,9 @@ const assignability4: () => AsyncIterableIterator = async function * () >yield* [Promise.resolve(1)] : any >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 }; @@ -149,9 +149,9 @@ const assignability7: () => AsyncIterable = async function * () { yield Promise.resolve(1); >yield Promise.resolve(1) : undefined >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 }; @@ -174,9 +174,9 @@ const assignability9: () => AsyncIterable = async function * () { >yield* [Promise.resolve(1)] : any >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 }; @@ -209,9 +209,9 @@ const assignability12: () => AsyncIterator = async function * () { yield Promise.resolve(1); >yield Promise.resolve(1) : undefined >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 }; @@ -234,9 +234,9 @@ const assignability14: () => AsyncIterator = async function * () { >yield* [Promise.resolve(1)] : any >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 }; @@ -266,9 +266,9 @@ async function * explicitReturnType2(): AsyncIterableIterator { yield Promise.resolve(1); >yield Promise.resolve(1) : undefined >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 } async function * explicitReturnType3(): AsyncIterableIterator { @@ -287,9 +287,9 @@ async function * explicitReturnType4(): AsyncIterableIterator { >yield* [Promise.resolve(1)] : any >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 } async function * explicitReturnType5(): AsyncIterableIterator { @@ -316,9 +316,9 @@ async function * explicitReturnType7(): AsyncIterable { yield Promise.resolve(1); >yield Promise.resolve(1) : undefined >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 } async function * explicitReturnType8(): AsyncIterable { @@ -337,9 +337,9 @@ async function * explicitReturnType9(): AsyncIterable { >yield* [Promise.resolve(1)] : any >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 } async function * explicitReturnType10(): AsyncIterable { @@ -366,9 +366,9 @@ async function * explicitReturnType12(): AsyncIterator { yield Promise.resolve(1); >yield Promise.resolve(1) : undefined >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 } async function * explicitReturnType13(): AsyncIterator { @@ -387,9 +387,9 @@ async function * explicitReturnType14(): AsyncIterator { >yield* [Promise.resolve(1)] : any >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 } async function * explicitReturnType15(): AsyncIterator { @@ -425,9 +425,9 @@ async function * awaitedType2() { >x : number >await Promise.resolve(1) : number >Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >1 : 1 } async function * nextType1(): { next(...args: [] | [number | PromiseLike]): any } { diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.2.types b/tests/baselines/reference/types.asyncGenerators.es2018.2.types index 8352487119937..c806140442836 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.2.types +++ b/tests/baselines/reference/types.asyncGenerators.es2018.2.types @@ -20,9 +20,9 @@ async function * inferReturnType3() { yield* Promise.resolve([1, 2]); >yield* Promise.resolve([1, 2]) : any >Promise.resolve([1, 2]) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >[1, 2] : number[] >1 : 1 >2 : 2 diff --git a/tests/baselines/reference/unionAndIntersectionInference1.types b/tests/baselines/reference/unionAndIntersectionInference1.types index 72d60545e6a51..58e5f6760aa2c 100644 --- a/tests/baselines/reference/unionAndIntersectionInference1.types +++ b/tests/baselines/reference/unionAndIntersectionInference1.types @@ -192,9 +192,9 @@ const createTestAsync = (): Promise => Promise.resolve().then(() => ({ na >Promise.resolve().then(() => ({ name: 'test' })) : Promise >Promise.resolve().then : (onfulfilled?: (value: void) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >Promise.resolve() : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >then : (onfulfilled?: (value: void) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => ({ name: 'test' }) : () => { name: "test"; } >({ name: 'test' }) : { name: "test"; } diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types index a321593c11a8c..c083abba7cb6d 100644 --- a/tests/baselines/reference/uniqueSymbols.types +++ b/tests/baselines/reference/uniqueSymbols.types @@ -400,9 +400,9 @@ const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNest const promiseForConstCall = Promise.resolve(constCall); >promiseForConstCall : Promise >Promise.resolve(constCall) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >constCall : unique symbol const arrayOfConstCall = [constCall]; diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.types b/tests/baselines/reference/uniqueSymbolsDeclarations.types index bacdafc5680db..6220359625a3c 100644 --- a/tests/baselines/reference/uniqueSymbolsDeclarations.types +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.types @@ -393,9 +393,9 @@ const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNest const promiseForConstCall = Promise.resolve(constCall); >promiseForConstCall : Promise >Promise.resolve(constCall) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise.resolve : { (value: T): Promise ? U : T>; (): Promise; } >Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>resolve : { (value: T): Promise ? U : T>; (): Promise; } >constCall : unique symbol const arrayOfConstCall = [constCall]; diff --git a/tests/baselines/reference/user/fp-ts.log b/tests/baselines/reference/user/fp-ts.log new file mode 100644 index 0000000000000..2a9f3a6ae131a --- /dev/null +++ b/tests/baselines/reference/user/fp-ts.log @@ -0,0 +1,12 @@ +Exit Code: 1 +Standard output: +src/Task.ts(105,16): error TS2322: Type 'Promise ? U : A>' is not assignable to type 'Promise'. + Type 'A extends PromiseLike ? U : A' is not assignable to type 'A'. + Type 'unknown' is not assignable to type 'A'. +src/Task.ts(114,16): error TS2322: Type 'Promise ? U : A>' is not assignable to type 'Promise'. + Type 'A extends PromiseLike ? U : A' is not assignable to type 'A'. + Type 'unknown' is not assignable to type 'A'. + + + +Standard error: diff --git a/tests/cases/compiler/asyncFunctionReturnType.ts b/tests/cases/compiler/asyncFunctionReturnType.ts index 3bd7a0e998ac2..2abc768a6c557 100644 --- a/tests/cases/compiler/asyncFunctionReturnType.ts +++ b/tests/cases/compiler/asyncFunctionReturnType.ts @@ -67,10 +67,10 @@ async function fGenericIndexedTypeForKProp(obj: TObj, key: K): Promise { +async function fGenericIndexedTypeForPromiseOfKProp(obj: TObj, key: K): Promise ? U : TObj[K]> { return Promise.resolve(obj[key]); } -async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise { +async function fGenericIndexedTypeForExplicitPromiseOfKProp(obj: TObj, key: K): Promise ? U : TObj[K]> { return Promise.resolve(obj[key]); -} \ No newline at end of file +}