mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Merge pull request #9204 from Microsoft/promiseAndAsyncUpdates
Update Promise and PromiseLike, fix async functions issues with never.
This commit is contained in:
@@ -37,14 +37,14 @@ export class BrokenClass {
|
||||
>reject : Symbol(reject, Decl(file1.ts, 13, 34))
|
||||
|
||||
this.doStuff(order.id)
|
||||
>this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>this.doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3))
|
||||
>this : Symbol(BrokenClass, Decl(file1.ts, 1, 39))
|
||||
>doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3))
|
||||
>order : Symbol(order, Decl(file1.ts, 12, 25))
|
||||
|
||||
.then((items) => {
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>items : Symbol(items, Decl(file1.ts, 15, 17))
|
||||
|
||||
order.items = items;
|
||||
@@ -60,17 +60,17 @@ export class BrokenClass {
|
||||
};
|
||||
|
||||
return Promise.all(result.map(populateItems))
|
||||
>Promise.all(result.map(populateItems)) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>Promise.all(result.map(populateItems)) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>result.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>result : Symbol(result, Decl(file1.ts, 10, 7))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>populateItems : Symbol(populateItems, Decl(file1.ts, 12, 7))
|
||||
|
||||
.then((orders: Array<MyModule.MyModel>) => {
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>orders : Symbol(orders, Decl(file1.ts, 23, 13))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6))
|
||||
|
||||
@@ -46,7 +46,7 @@ export class BrokenClass {
|
||||
|
||||
this.doStuff(order.id)
|
||||
>this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }) : Promise<void>
|
||||
>this.doStuff(order.id) .then : { <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>this.doStuff(order.id) .then : { <TResult1, TResult2>(onfulfilled: (value: void) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: void) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: void) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<void>; }
|
||||
>this.doStuff(order.id) : Promise<void>
|
||||
>this.doStuff : (id: number) => Promise<void>
|
||||
>this : this
|
||||
@@ -56,7 +56,7 @@ export class BrokenClass {
|
||||
>id : any
|
||||
|
||||
.then((items) => {
|
||||
>then : { <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: void) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: void) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: void) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<void>; }
|
||||
>(items) => { order.items = items; resolve(order); } : (items: void) => void
|
||||
>items : void
|
||||
|
||||
@@ -78,11 +78,11 @@ export class BrokenClass {
|
||||
|
||||
return Promise.all(result.map(populateItems))
|
||||
>Promise.all(result.map(populateItems)) .then((orders: Array<MyModule.MyModel>) => { resolve(orders); }) : Promise<void>
|
||||
>Promise.all(result.map(populateItems)) .then : { <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>Promise.all(result.map(populateItems)) .then : { <TResult1, TResult2>(onfulfilled: (value: {}[]) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}[]) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}[]>; }
|
||||
>Promise.all(result.map(populateItems)) : Promise<{}[]>
|
||||
>Promise.all : { <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>; <T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; }
|
||||
>Promise.all : { <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>; <T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: (T | PromiseLike<T>)[]): Promise<T[]>; <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; }
|
||||
>Promise : PromiseConstructor
|
||||
>all : { <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>; <T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; }
|
||||
>all : { <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>; <T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: (T | PromiseLike<T>)[]): Promise<T[]>; <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; }
|
||||
>result.map(populateItems) : Promise<{}>[]
|
||||
>result.map : <U>(callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any) => U[]
|
||||
>result : MyModule.MyModel[]
|
||||
@@ -90,7 +90,7 @@ export class BrokenClass {
|
||||
>populateItems : (order: any) => Promise<{}>
|
||||
|
||||
.then((orders: Array<MyModule.MyModel>) => {
|
||||
>then : { <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: {}[]) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}[]) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}[]>; }
|
||||
>(orders: Array<MyModule.MyModel>) => { resolve(orders); } : (orders: MyModule.MyModel[]) => void
|
||||
>orders : MyModule.MyModel[]
|
||||
>Array : T[]
|
||||
|
||||
@@ -121,9 +121,9 @@ declare var console: any;
|
||||
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 52, 11))
|
||||
|
||||
out().then(() => {
|
||||
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 45, 37))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
|
||||
console.log("Yea!");
|
||||
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 52, 11))
|
||||
|
||||
@@ -148,10 +148,10 @@ declare var console: any;
|
||||
|
||||
out().then(() => {
|
||||
>out().then(() => { console.log("Yea!");}) : Promise<void>
|
||||
>out().then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>out().then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
|
||||
>out() : Promise<{}>
|
||||
>out : () => Promise<{}>
|
||||
>then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
|
||||
>() => { console.log("Yea!");} : () => void
|
||||
|
||||
console.log("Yea!");
|
||||
|
||||
@@ -121,9 +121,9 @@ declare var console: any;
|
||||
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 52, 11))
|
||||
|
||||
out().then(() => {
|
||||
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 45, 37))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
|
||||
console.log("Yea!");
|
||||
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 52, 11))
|
||||
|
||||
@@ -148,10 +148,10 @@ declare var console: any;
|
||||
|
||||
out().then(() => {
|
||||
>out().then(() => { console.log("Yea!");}) : Promise<void>
|
||||
>out().then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>out().then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
|
||||
>out() : Promise<{}>
|
||||
>out : () => Promise<{}>
|
||||
>then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
|
||||
>() => { console.log("Yea!");} : () => void
|
||||
|
||||
console.log("Yea!");
|
||||
|
||||
@@ -121,9 +121,9 @@ declare var console: any;
|
||||
>console : Symbol(console, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 52, 11))
|
||||
|
||||
out().then(() => {
|
||||
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>out : Symbol(out, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 45, 37))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
|
||||
console.log("Yea!");
|
||||
>console : Symbol(console, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 52, 11))
|
||||
|
||||
@@ -148,10 +148,10 @@ declare var console: any;
|
||||
|
||||
out().then(() => {
|
||||
>out().then(() => { console.log("Yea!");}) : Promise<void>
|
||||
>out().then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>out().then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
|
||||
>out() : Promise<{}>
|
||||
>out : () => Promise<{}>
|
||||
>then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
|
||||
>() => { console.log("Yea!");} : () => void
|
||||
|
||||
console.log("Yea!");
|
||||
|
||||
202
tests/baselines/reference/promiseType.js
Normal file
202
tests/baselines/reference/promiseType.js
Normal file
@@ -0,0 +1,202 @@
|
||||
//// [promiseType.ts]
|
||||
declare var p: Promise<boolean>;
|
||||
|
||||
const a = p.then();
|
||||
const b = p.then(b => 1);
|
||||
const c = p.then(b => 1, e => 'error');
|
||||
const d = p.then(b => 1, e => { });
|
||||
const e = p.then(b => 1, e => { throw Error(); });
|
||||
const f = p.then(b => 1, e => Promise.reject(Error()));
|
||||
const g = p.catch(e => 'error');
|
||||
const h = p.catch(e => { });
|
||||
const i = p.catch(e => { throw Error(); });
|
||||
const j = p.catch(e => Promise.reject(Error()));
|
||||
|
||||
async function A() {
|
||||
const a = await p;
|
||||
return a;
|
||||
}
|
||||
|
||||
async function B() {
|
||||
const a = await p;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// NOTE: This reports a "No best comment type exists among return expressions." error, and is
|
||||
// ignored to get the types result for the test.
|
||||
// async function C() {
|
||||
// try {
|
||||
// const a = await p;
|
||||
// return 1;
|
||||
// }
|
||||
// catch (e) {
|
||||
// return 'error';
|
||||
// }
|
||||
// }
|
||||
|
||||
async function D() {
|
||||
try {
|
||||
const a = await p;
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
async function E() {
|
||||
try {
|
||||
const a = await p;
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
throw Error();
|
||||
}
|
||||
}
|
||||
|
||||
async function F() {
|
||||
try {
|
||||
const a = await p;
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
return Promise.reject(Error());
|
||||
}
|
||||
}
|
||||
|
||||
async function G() {
|
||||
try {
|
||||
const a = await p;
|
||||
return a;
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function H() {
|
||||
try {
|
||||
const a = await p;
|
||||
return a;
|
||||
}
|
||||
catch (e) {
|
||||
throw Error();
|
||||
}
|
||||
}
|
||||
|
||||
async function I() {
|
||||
try {
|
||||
const a = await p;
|
||||
return a;
|
||||
}
|
||||
catch (e) {
|
||||
return Promise.reject(Error());
|
||||
}
|
||||
}
|
||||
|
||||
//// [promiseType.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
};
|
||||
const a = p.then();
|
||||
const b = p.then(b => 1);
|
||||
const c = p.then(b => 1, e => 'error');
|
||||
const d = p.then(b => 1, e => { });
|
||||
const e = p.then(b => 1, e => { throw Error(); });
|
||||
const f = p.then(b => 1, e => Promise.reject(Error()));
|
||||
const g = p.catch(e => 'error');
|
||||
const h = p.catch(e => { });
|
||||
const i = p.catch(e => { throw Error(); });
|
||||
const j = p.catch(e => Promise.reject(Error()));
|
||||
function A() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const a = yield p;
|
||||
return a;
|
||||
});
|
||||
}
|
||||
function B() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const a = yield p;
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
// NOTE: This reports a "No best comment type exists among return expressions." error, and is
|
||||
// ignored to get the types result for the test.
|
||||
// async function C() {
|
||||
// try {
|
||||
// const a = await p;
|
||||
// return 1;
|
||||
// }
|
||||
// catch (e) {
|
||||
// return 'error';
|
||||
// }
|
||||
// }
|
||||
function D() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const a = yield p;
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
function E() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const a = yield p;
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
throw Error();
|
||||
}
|
||||
});
|
||||
}
|
||||
function F() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const a = yield p;
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
return Promise.reject(Error());
|
||||
}
|
||||
});
|
||||
}
|
||||
function G() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const a = yield p;
|
||||
return a;
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
function H() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const a = yield p;
|
||||
return a;
|
||||
}
|
||||
catch (e) {
|
||||
throw Error();
|
||||
}
|
||||
});
|
||||
}
|
||||
function I() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const a = yield p;
|
||||
return a;
|
||||
}
|
||||
catch (e) {
|
||||
return Promise.reject(Error());
|
||||
}
|
||||
});
|
||||
}
|
||||
233
tests/baselines/reference/promiseType.symbols
Normal file
233
tests/baselines/reference/promiseType.symbols
Normal file
@@ -0,0 +1,233 @@
|
||||
=== tests/cases/compiler/promiseType.ts ===
|
||||
declare var p: Promise<boolean>;
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
const a = p.then();
|
||||
>a : Symbol(a, Decl(promiseType.ts, 2, 5))
|
||||
>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
|
||||
const b = p.then(b => 1);
|
||||
>b : Symbol(b, Decl(promiseType.ts, 3, 5))
|
||||
>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>b : Symbol(b, Decl(promiseType.ts, 3, 17))
|
||||
|
||||
const c = p.then(b => 1, e => 'error');
|
||||
>c : Symbol(c, Decl(promiseType.ts, 4, 5))
|
||||
>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>b : Symbol(b, Decl(promiseType.ts, 4, 17))
|
||||
>e : Symbol(e, Decl(promiseType.ts, 4, 24))
|
||||
|
||||
const d = p.then(b => 1, e => { });
|
||||
>d : Symbol(d, Decl(promiseType.ts, 5, 5))
|
||||
>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>b : Symbol(b, Decl(promiseType.ts, 5, 17))
|
||||
>e : Symbol(e, Decl(promiseType.ts, 5, 24))
|
||||
|
||||
const e = p.then(b => 1, e => { throw Error(); });
|
||||
>e : Symbol(e, Decl(promiseType.ts, 6, 5))
|
||||
>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>b : Symbol(b, Decl(promiseType.ts, 6, 17))
|
||||
>e : Symbol(e, Decl(promiseType.ts, 6, 24))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
const f = p.then(b => 1, e => Promise.reject(Error()));
|
||||
>f : Symbol(f, Decl(promiseType.ts, 7, 5))
|
||||
>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>b : Symbol(b, Decl(promiseType.ts, 7, 17))
|
||||
>e : Symbol(e, Decl(promiseType.ts, 7, 24))
|
||||
>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
const g = p.catch(e => 'error');
|
||||
>g : Symbol(g, Decl(promiseType.ts, 8, 5))
|
||||
>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>e : Symbol(e, Decl(promiseType.ts, 8, 18))
|
||||
|
||||
const h = p.catch(e => { });
|
||||
>h : Symbol(h, Decl(promiseType.ts, 9, 5))
|
||||
>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>e : Symbol(e, Decl(promiseType.ts, 9, 18))
|
||||
|
||||
const i = p.catch(e => { throw Error(); });
|
||||
>i : Symbol(i, Decl(promiseType.ts, 10, 5))
|
||||
>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>e : Symbol(e, Decl(promiseType.ts, 10, 18))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
const j = p.catch(e => Promise.reject(Error()));
|
||||
>j : Symbol(j, Decl(promiseType.ts, 11, 5))
|
||||
>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>e : Symbol(e, Decl(promiseType.ts, 11, 18))
|
||||
>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
async function A() {
|
||||
>A : Symbol(A, Decl(promiseType.ts, 11, 48))
|
||||
|
||||
const a = await p;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 14, 9))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
|
||||
return a;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 14, 9))
|
||||
}
|
||||
|
||||
async function B() {
|
||||
>B : Symbol(B, Decl(promiseType.ts, 16, 1))
|
||||
|
||||
const a = await p;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 19, 9))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// NOTE: This reports a "No best comment type exists among return expressions." error, and is
|
||||
// ignored to get the types result for the test.
|
||||
// async function C() {
|
||||
// try {
|
||||
// const a = await p;
|
||||
// return 1;
|
||||
// }
|
||||
// catch (e) {
|
||||
// return 'error';
|
||||
// }
|
||||
// }
|
||||
|
||||
async function D() {
|
||||
>D : Symbol(D, Decl(promiseType.ts, 21, 1))
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 37, 13))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
>e : Symbol(e, Decl(promiseType.ts, 40, 11))
|
||||
}
|
||||
}
|
||||
|
||||
async function E() {
|
||||
>E : Symbol(E, Decl(promiseType.ts, 42, 1))
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 46, 13))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
>e : Symbol(e, Decl(promiseType.ts, 49, 11))
|
||||
|
||||
throw Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
|
||||
async function F() {
|
||||
>F : Symbol(F, Decl(promiseType.ts, 52, 1))
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 56, 13))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
>e : Symbol(e, Decl(promiseType.ts, 59, 11))
|
||||
|
||||
return Promise.reject(Error());
|
||||
>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
|
||||
async function G() {
|
||||
>G : Symbol(G, Decl(promiseType.ts, 62, 1))
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 66, 13))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
|
||||
return a;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 66, 13))
|
||||
}
|
||||
catch (e) {
|
||||
>e : Symbol(e, Decl(promiseType.ts, 69, 11))
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function H() {
|
||||
>H : Symbol(H, Decl(promiseType.ts, 72, 1))
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 76, 13))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
|
||||
return a;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 76, 13))
|
||||
}
|
||||
catch (e) {
|
||||
>e : Symbol(e, Decl(promiseType.ts, 79, 11))
|
||||
|
||||
throw Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
|
||||
async function I() {
|
||||
>I : Symbol(I, Decl(promiseType.ts, 82, 1))
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 86, 13))
|
||||
>p : Symbol(p, Decl(promiseType.ts, 0, 11))
|
||||
|
||||
return a;
|
||||
>a : Symbol(a, Decl(promiseType.ts, 86, 13))
|
||||
}
|
||||
catch (e) {
|
||||
>e : Symbol(e, Decl(promiseType.ts, 89, 11))
|
||||
|
||||
return Promise.reject(Error());
|
||||
>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
287
tests/baselines/reference/promiseType.types
Normal file
287
tests/baselines/reference/promiseType.types
Normal file
@@ -0,0 +1,287 @@
|
||||
=== tests/cases/compiler/promiseType.ts ===
|
||||
declare var p: Promise<boolean>;
|
||||
>p : Promise<boolean>
|
||||
>Promise : Promise<T>
|
||||
|
||||
const a = p.then();
|
||||
>a : Promise<boolean>
|
||||
>p.then() : Promise<boolean>
|
||||
>p.then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
>p : Promise<boolean>
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
|
||||
const b = p.then(b => 1);
|
||||
>b : Promise<number>
|
||||
>p.then(b => 1) : Promise<number>
|
||||
>p.then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
>p : Promise<boolean>
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
>b => 1 : (b: boolean) => number
|
||||
>b : boolean
|
||||
>1 : number
|
||||
|
||||
const c = p.then(b => 1, e => 'error');
|
||||
>c : Promise<number | string>
|
||||
>p.then(b => 1, e => 'error') : Promise<number | string>
|
||||
>p.then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
>p : Promise<boolean>
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
>b => 1 : (b: boolean) => number
|
||||
>b : boolean
|
||||
>1 : number
|
||||
>e => 'error' : (e: any) => string
|
||||
>e : any
|
||||
>'error' : string
|
||||
|
||||
const d = p.then(b => 1, e => { });
|
||||
>d : Promise<number | void>
|
||||
>p.then(b => 1, e => { }) : Promise<number | void>
|
||||
>p.then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
>p : Promise<boolean>
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
>b => 1 : (b: boolean) => number
|
||||
>b : boolean
|
||||
>1 : number
|
||||
>e => { } : (e: any) => void
|
||||
>e : any
|
||||
|
||||
const e = p.then(b => 1, e => { throw Error(); });
|
||||
>e : Promise<number>
|
||||
>p.then(b => 1, e => { throw Error(); }) : Promise<number>
|
||||
>p.then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
>p : Promise<boolean>
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
>b => 1 : (b: boolean) => number
|
||||
>b : boolean
|
||||
>1 : number
|
||||
>e => { throw Error(); } : (e: any) => never
|
||||
>e : any
|
||||
>Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
|
||||
const f = p.then(b => 1, e => Promise.reject(Error()));
|
||||
>f : Promise<number>
|
||||
>p.then(b => 1, e => Promise.reject(Error())) : Promise<number>
|
||||
>p.then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
>p : Promise<boolean>
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: boolean) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: boolean) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<boolean>; }
|
||||
>b => 1 : (b: boolean) => number
|
||||
>b : boolean
|
||||
>1 : number
|
||||
>e => Promise.reject(Error()) : (e: any) => Promise<never>
|
||||
>e : any
|
||||
>Promise.reject(Error()) : Promise<never>
|
||||
>Promise.reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<T>; }
|
||||
>Promise : PromiseConstructor
|
||||
>reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<T>; }
|
||||
>Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
|
||||
const g = p.catch(e => 'error');
|
||||
>g : Promise<boolean | string>
|
||||
>p.catch(e => 'error') : Promise<boolean | string>
|
||||
>p.catch : { <TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<boolean | TResult>; (onrejected: (reason: any) => boolean | PromiseLike<boolean>): Promise<boolean>; }
|
||||
>p : Promise<boolean>
|
||||
>catch : { <TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<boolean | TResult>; (onrejected: (reason: any) => boolean | PromiseLike<boolean>): Promise<boolean>; }
|
||||
>e => 'error' : (e: any) => string
|
||||
>e : any
|
||||
>'error' : string
|
||||
|
||||
const h = p.catch(e => { });
|
||||
>h : Promise<boolean | void>
|
||||
>p.catch(e => { }) : Promise<boolean | void>
|
||||
>p.catch : { <TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<boolean | TResult>; (onrejected: (reason: any) => boolean | PromiseLike<boolean>): Promise<boolean>; }
|
||||
>p : Promise<boolean>
|
||||
>catch : { <TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<boolean | TResult>; (onrejected: (reason: any) => boolean | PromiseLike<boolean>): Promise<boolean>; }
|
||||
>e => { } : (e: any) => void
|
||||
>e : any
|
||||
|
||||
const i = p.catch(e => { throw Error(); });
|
||||
>i : Promise<boolean>
|
||||
>p.catch(e => { throw Error(); }) : Promise<boolean>
|
||||
>p.catch : { <TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<boolean | TResult>; (onrejected: (reason: any) => boolean | PromiseLike<boolean>): Promise<boolean>; }
|
||||
>p : Promise<boolean>
|
||||
>catch : { <TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<boolean | TResult>; (onrejected: (reason: any) => boolean | PromiseLike<boolean>): Promise<boolean>; }
|
||||
>e => { throw Error(); } : (e: any) => never
|
||||
>e : any
|
||||
>Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
|
||||
const j = p.catch(e => Promise.reject(Error()));
|
||||
>j : Promise<boolean>
|
||||
>p.catch(e => Promise.reject(Error())) : Promise<boolean>
|
||||
>p.catch : { <TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<boolean | TResult>; (onrejected: (reason: any) => boolean | PromiseLike<boolean>): Promise<boolean>; }
|
||||
>p : Promise<boolean>
|
||||
>catch : { <TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<boolean | TResult>; (onrejected: (reason: any) => boolean | PromiseLike<boolean>): Promise<boolean>; }
|
||||
>e => Promise.reject(Error()) : (e: any) => Promise<never>
|
||||
>e : any
|
||||
>Promise.reject(Error()) : Promise<never>
|
||||
>Promise.reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<T>; }
|
||||
>Promise : PromiseConstructor
|
||||
>reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<T>; }
|
||||
>Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
|
||||
async function A() {
|
||||
>A : () => Promise<boolean>
|
||||
|
||||
const a = await p;
|
||||
>a : boolean
|
||||
>await p : boolean
|
||||
>p : Promise<boolean>
|
||||
|
||||
return a;
|
||||
>a : boolean
|
||||
}
|
||||
|
||||
async function B() {
|
||||
>B : () => Promise<number>
|
||||
|
||||
const a = await p;
|
||||
>a : boolean
|
||||
>await p : boolean
|
||||
>p : Promise<boolean>
|
||||
|
||||
return 1;
|
||||
>1 : number
|
||||
}
|
||||
|
||||
// NOTE: This reports a "No best comment type exists among return expressions." error, and is
|
||||
// ignored to get the types result for the test.
|
||||
// async function C() {
|
||||
// try {
|
||||
// const a = await p;
|
||||
// return 1;
|
||||
// }
|
||||
// catch (e) {
|
||||
// return 'error';
|
||||
// }
|
||||
// }
|
||||
|
||||
async function D() {
|
||||
>D : () => Promise<number>
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : boolean
|
||||
>await p : boolean
|
||||
>p : Promise<boolean>
|
||||
|
||||
return 1;
|
||||
>1 : number
|
||||
}
|
||||
catch (e) {
|
||||
>e : any
|
||||
}
|
||||
}
|
||||
|
||||
async function E() {
|
||||
>E : () => Promise<number>
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : boolean
|
||||
>await p : boolean
|
||||
>p : Promise<boolean>
|
||||
|
||||
return 1;
|
||||
>1 : number
|
||||
}
|
||||
catch (e) {
|
||||
>e : any
|
||||
|
||||
throw Error();
|
||||
>Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
}
|
||||
|
||||
async function F() {
|
||||
>F : () => Promise<number>
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : boolean
|
||||
>await p : boolean
|
||||
>p : Promise<boolean>
|
||||
|
||||
return 1;
|
||||
>1 : number
|
||||
}
|
||||
catch (e) {
|
||||
>e : any
|
||||
|
||||
return Promise.reject(Error());
|
||||
>Promise.reject(Error()) : Promise<never>
|
||||
>Promise.reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<T>; }
|
||||
>Promise : PromiseConstructor
|
||||
>reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<T>; }
|
||||
>Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
}
|
||||
|
||||
async function G() {
|
||||
>G : () => Promise<boolean>
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : boolean
|
||||
>await p : boolean
|
||||
>p : Promise<boolean>
|
||||
|
||||
return a;
|
||||
>a : boolean
|
||||
}
|
||||
catch (e) {
|
||||
>e : any
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function H() {
|
||||
>H : () => Promise<boolean>
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : boolean
|
||||
>await p : boolean
|
||||
>p : Promise<boolean>
|
||||
|
||||
return a;
|
||||
>a : boolean
|
||||
}
|
||||
catch (e) {
|
||||
>e : any
|
||||
|
||||
throw Error();
|
||||
>Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
}
|
||||
|
||||
async function I() {
|
||||
>I : () => Promise<boolean>
|
||||
|
||||
try {
|
||||
const a = await p;
|
||||
>a : boolean
|
||||
>await p : boolean
|
||||
>p : Promise<boolean>
|
||||
|
||||
return a;
|
||||
>a : boolean
|
||||
}
|
||||
catch (e) {
|
||||
>e : any
|
||||
|
||||
return Promise.reject(Error());
|
||||
>Promise.reject(Error()) : Promise<never>
|
||||
>Promise.reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<T>; }
|
||||
>Promise : PromiseConstructor
|
||||
>reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<T>; }
|
||||
>Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
}
|
||||
@@ -47,12 +47,12 @@ function f2(x: T1): T2 {
|
||||
|
||||
var x3 = f1()
|
||||
>x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3))
|
||||
>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>f1() .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>f1() .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1))
|
||||
|
||||
.then(f2, (e: Error) => {
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1))
|
||||
>e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
@@ -62,7 +62,7 @@ var x3 = f1()
|
||||
|
||||
})
|
||||
.then((x: T2) => {
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11))
|
||||
>T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1))
|
||||
|
||||
|
||||
@@ -54,14 +54,14 @@ function f2(x: T1): T2 {
|
||||
var x3 = f1()
|
||||
>x3 : Promise<{ __t3: string; }>
|
||||
>f1() .then(f2, (e: Error) => { throw e;}) .then((x: T2) => { return { __t3: x.__t2 + "bar" };}) : Promise<{ __t3: string; }>
|
||||
>f1() .then(f2, (e: Error) => { throw e;}) .then : { <TResult>(onfulfilled?: (value: T2) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: T2) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>f1() .then(f2, (e: Error) => { throw e;}) .then : { <TResult1, TResult2>(onfulfilled: (value: T2) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: T2) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: T2) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<T2>; }
|
||||
>f1() .then(f2, (e: Error) => { throw e;}) : Promise<T2>
|
||||
>f1() .then : { <TResult>(onfulfilled?: (value: T1) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: T1) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>f1() .then : { <TResult1, TResult2>(onfulfilled: (value: T1) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: T1) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: T1) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<T1>; }
|
||||
>f1() : Promise<T1>
|
||||
>f1 : () => Promise<T1>
|
||||
|
||||
.then(f2, (e: Error) => {
|
||||
>then : { <TResult>(onfulfilled?: (value: T1) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: T1) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: T1) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: T1) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: T1) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<T1>; }
|
||||
>f2 : (x: T1) => T2
|
||||
>(e: Error) => { throw e;} : (e: Error) => never
|
||||
>e : Error
|
||||
@@ -72,7 +72,7 @@ var x3 = f1()
|
||||
|
||||
})
|
||||
.then((x: T2) => {
|
||||
>then : { <TResult>(onfulfilled?: (value: T2) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: T2) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>then : { <TResult1, TResult2>(onfulfilled: (value: T2) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: T2) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: T2) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<T2>; }
|
||||
>(x: T2) => { return { __t3: x.__t2 + "bar" };} : (x: T2) => { __t3: string; }
|
||||
>x : T2
|
||||
>T2 : T2
|
||||
|
||||
94
tests/cases/compiler/promiseType.ts
Normal file
94
tests/cases/compiler/promiseType.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
// @target: es6
|
||||
declare var p: Promise<boolean>;
|
||||
|
||||
const a = p.then();
|
||||
const b = p.then(b => 1);
|
||||
const c = p.then(b => 1, e => 'error');
|
||||
const d = p.then(b => 1, e => { });
|
||||
const e = p.then(b => 1, e => { throw Error(); });
|
||||
const f = p.then(b => 1, e => Promise.reject(Error()));
|
||||
const g = p.catch(e => 'error');
|
||||
const h = p.catch(e => { });
|
||||
const i = p.catch(e => { throw Error(); });
|
||||
const j = p.catch(e => Promise.reject(Error()));
|
||||
|
||||
async function A() {
|
||||
const a = await p;
|
||||
return a;
|
||||
}
|
||||
|
||||
async function B() {
|
||||
const a = await p;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// NOTE: This reports a "No best comment type exists among return expressions." error, and is
|
||||
// ignored to get the types result for the test.
|
||||
// async function C() {
|
||||
// try {
|
||||
// const a = await p;
|
||||
// return 1;
|
||||
// }
|
||||
// catch (e) {
|
||||
// return 'error';
|
||||
// }
|
||||
// }
|
||||
|
||||
async function D() {
|
||||
try {
|
||||
const a = await p;
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
async function E() {
|
||||
try {
|
||||
const a = await p;
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
throw Error();
|
||||
}
|
||||
}
|
||||
|
||||
async function F() {
|
||||
try {
|
||||
const a = await p;
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
return Promise.reject(Error());
|
||||
}
|
||||
}
|
||||
|
||||
async function G() {
|
||||
try {
|
||||
const a = await p;
|
||||
return a;
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function H() {
|
||||
try {
|
||||
const a = await p;
|
||||
return a;
|
||||
}
|
||||
catch (e) {
|
||||
throw Error();
|
||||
}
|
||||
}
|
||||
|
||||
async function I() {
|
||||
try {
|
||||
const a = await p;
|
||||
return a;
|
||||
}
|
||||
catch (e) {
|
||||
return Promise.reject(Error());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user