Skip to content

Commit

Permalink
Better typings for Promise.resolve(), like #31117
Browse files Browse the repository at this point in the history
  • Loading branch information
jablko committed Dec 25, 2019
1 parent 2ec4722 commit cba82b5
Show file tree
Hide file tree
Showing 23 changed files with 218 additions and 193 deletions.
2 changes: 1 addition & 1 deletion src/lib/es2015.promise.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ interface PromiseConstructor {
* @param value A promise.
* @returns A promise whose internal state matches the provided promise.
*/
resolve<T>(value: T | PromiseLike<T>): Promise<T>;
resolve<T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>;

/**
* Creates a new resolved promise .
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/asyncArrowFunction11_es5.types
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class A {
await Promise.resolve();
>await Promise.resolve() : void
>Promise.resolve() : Promise<void>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }

const obj = { ["a"]: () => this }; // computed property name after `await` triggers case
>obj : { a: () => this; }
Expand Down
7 changes: 4 additions & 3 deletions tests/baselines/reference/asyncFunctionReturnType.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ async function fGenericIndexedTypeForKProp<TObj extends Obj, K extends keyof TOb
return obj[key];
}

async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K] extends PromiseLike<infer U> ? U : TObj[K]> {
return Promise.resolve(obj[key]);
}

async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K] extends PromiseLike<infer U> ? U : TObj[K]> {
return Promise.resolve<TObj[K]>(obj[key]);
}
}


//// [asyncFunctionReturnType.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
Expand Down
15 changes: 13 additions & 2 deletions tests/baselines/reference/asyncFunctionReturnType.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async function fGenericIndexedTypeForKProp<TObj extends Obj, K extends keyof TOb
>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 64, 93))
}

async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K] extends PromiseLike<infer U> ? 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))
Expand All @@ -252,6 +252,11 @@ async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends
>K : 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]);
Expand All @@ -262,7 +267,7 @@ async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends
>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 68, 102))
}

async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K] extends PromiseLike<infer U> ? 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))
Expand All @@ -274,6 +279,11 @@ async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K
>K : 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<TObj[K]>(obj[key]);
Expand All @@ -285,3 +295,4 @@ async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K
>obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 72, 100))
>key : Symbol(key, Decl(asyncFunctionReturnType.ts, 72, 110))
}

57 changes: 29 additions & 28 deletions tests/baselines/reference/asyncFunctionReturnType.types
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ async function fIndexedTypeForPromiseOfStringProp(obj: Obj): Promise<Obj["string

return Promise.resolve(obj.stringProp);
>Promise.resolve(obj.stringProp) : Promise<string>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>obj.stringProp : string
>obj : Obj
>stringProp : string
Expand All @@ -58,9 +58,9 @@ async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise<Obj

return Promise.resolve<Obj["stringProp"]>(obj.stringProp);
>Promise.resolve<Obj["stringProp"]>(obj.stringProp) : Promise<string>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>obj.stringProp : string
>obj : Obj
>stringProp : string
Expand All @@ -82,9 +82,9 @@ async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]

return Promise.resolve(obj.anyProp);
>Promise.resolve(obj.anyProp) : Promise<any>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>obj.anyProp : any
>obj : Obj
>anyProp : any
Expand All @@ -96,9 +96,9 @@ async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise<Obj["a

return Promise.resolve<Obj["anyProp"]>(obj.anyProp);
>Promise.resolve<Obj["anyProp"]>(obj.anyProp) : Promise<any>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>obj.anyProp : any
>obj : Obj
>anyProp : any
Expand All @@ -120,9 +120,9 @@ async function fGenericIndexedTypeForPromiseOfStringProp<TObj extends Obj>(obj:

return Promise.resolve(obj.stringProp);
>Promise.resolve(obj.stringProp) : Promise<string>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>obj.stringProp : string
>obj : TObj
>stringProp : string
Expand All @@ -133,10 +133,10 @@ async function fGenericIndexedTypeForExplicitPromiseOfStringProp<TObj extends Ob
>obj : TObj

return Promise.resolve<TObj["stringProp"]>(obj.stringProp);
>Promise.resolve<TObj["stringProp"]>(obj.stringProp) : Promise<TObj["stringProp"]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve<TObj["stringProp"]>(obj.stringProp) : Promise<TObj["stringProp"] extends PromiseLike<infer U> ? U : TObj["stringProp"]>
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>obj.stringProp : string
>obj : TObj
>stringProp : string
Expand All @@ -158,9 +158,9 @@ async function fGenericIndexedTypeForPromiseOfAnyProp<TObj extends Obj>(obj: TOb

return Promise.resolve(obj.anyProp);
>Promise.resolve(obj.anyProp) : Promise<any>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>obj.anyProp : any
>obj : TObj
>anyProp : any
Expand All @@ -171,10 +171,10 @@ async function fGenericIndexedTypeForExplicitPromiseOfAnyProp<TObj extends Obj>(
>obj : TObj

return Promise.resolve<TObj["anyProp"]>(obj.anyProp);
>Promise.resolve<TObj["anyProp"]>(obj.anyProp) : Promise<TObj["anyProp"]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve<TObj["anyProp"]>(obj.anyProp) : Promise<TObj["anyProp"] extends PromiseLike<infer U> ? U : TObj["anyProp"]>
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>obj.anyProp : any
>obj : TObj
>anyProp : any
Expand All @@ -191,32 +191,33 @@ async function fGenericIndexedTypeForKProp<TObj extends Obj, K extends keyof TOb
>key : K
}

async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
>fGenericIndexedTypeForPromiseOfKProp : <TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K) => Promise<TObj[K]>
async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K] extends PromiseLike<infer U> ? U : TObj[K]> {
>fGenericIndexedTypeForPromiseOfKProp : <TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K) => Promise<TObj[K] extends PromiseLike<infer U> ? U : TObj[K]>
>obj : TObj
>key : K

return Promise.resolve(obj[key]);
>Promise.resolve(obj[key]) : Promise<TObj[K]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve(obj[key]) : Promise<TObj[K] extends PromiseLike<infer U> ? U : TObj[K]>
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>obj[key] : TObj[K]
>obj : TObj
>key : K
}

async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
>fGenericIndexedTypeForExplicitPromiseOfKProp : <TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K) => Promise<TObj[K]>
async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K] extends PromiseLike<infer U> ? U : TObj[K]> {
>fGenericIndexedTypeForExplicitPromiseOfKProp : <TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K) => Promise<TObj[K] extends PromiseLike<infer U> ? U : TObj[K]>
>obj : TObj
>key : K

return Promise.resolve<TObj[K]>(obj[key]);
>Promise.resolve<TObj[K]>(obj[key]) : Promise<TObj[K]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve<TObj[K]>(obj[key]) : Promise<TObj[K] extends PromiseLike<infer U> ? U : TObj[K]>
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>obj[key] : TObj[K]
>obj : TObj
>key : K
}

4 changes: 2 additions & 2 deletions tests/baselines/reference/exportDefaultAsyncFunction2.types
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export default async(() => await(Promise.resolve(1)));
>await(Promise.resolve(1)) : any
>await : (...args: any[]) => any
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>1 : 1

=== tests/cases/compiler/b.ts ===
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/genericFunctionInference1.types
Original file line number Diff line number Diff line change
Expand Up @@ -835,9 +835,9 @@ const fn30: Fn = pipe(
const promise = Promise.resolve(1);
>promise : Promise<number>
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>1 : 1

promise.then(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ function truePromise(): Promise<true> {

return Promise.resolve(true);
>Promise.resolve(true) : Promise<true>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>true : true
}

Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/instantiateContextualTypes.types
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ class Interesting {
>Promise.resolve().then(() => { if (1 < 2) { return 'SOMETHING'; } return 'ELSE'; }) : Promise<DooDad>
>Promise.resolve().then : <TResult1 = void, TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>
>Promise.resolve() : Promise<void>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>then : <TResult1 = void, TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>
>() => { if (1 < 2) { return 'SOMETHING'; } return 'ELSE'; } : () => "SOMETHING" | "ELSE"

Expand All @@ -369,9 +369,9 @@ class Interesting {
>Promise.resolve().then(() => { return 'ELSE'; }) : Promise<DooDad>
>Promise.resolve().then : <TResult1 = void, TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>
>Promise.resolve() : Promise<void>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>then : <TResult1 = void, TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>
>() => { return 'ELSE'; } : () => "ELSE"

Expand All @@ -388,9 +388,9 @@ class Interesting {
>Promise.resolve().then(() => { if (1 < 2) { return 'SOMETHING'; } return 'SOMETHING'; }) : Promise<DooDad>
>Promise.resolve().then : <TResult1 = void, TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>
>Promise.resolve() : Promise<void>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>then : <TResult1 = void, TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>
>() => { if (1 < 2) { return 'SOMETHING'; } return 'SOMETHING'; } : () => "SOMETHING"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ function returnAnyArray(arr) {
var anyPromise = Promise.resolve(5);
>anyPromise : Promise<any>
>Promise.resolve(5) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>5 : 5

/** @type {Promise<number>} */
var numberPromise = Promise.resolve(5);
>numberPromise : Promise<number>
>Promise.resolve(5) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<T extends PromiseLike<infer U> ? U : T>; (): Promise<void>; }
>5 : 5

/**
Expand Down
Loading

0 comments on commit cba82b5

Please sign in to comment.