mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Merge pull request #9204 from Microsoft/promiseAndAsyncUpdates
Update Promise and PromiseLike, fix async functions issues with never.
This commit is contained in:
commit
12bfb7e987
@ -2794,6 +2794,10 @@ namespace ts {
|
||||
return type && (type.flags & TypeFlags.Any) !== 0;
|
||||
}
|
||||
|
||||
function isTypeNever(type: Type) {
|
||||
return type && (type.flags & TypeFlags.Never) !== 0;
|
||||
}
|
||||
|
||||
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
||||
// assigned by contextual typing.
|
||||
function getTypeForBindingElementParent(node: VariableLikeDeclaration) {
|
||||
@ -11779,6 +11783,16 @@ namespace ts {
|
||||
return emptyObjectType;
|
||||
}
|
||||
|
||||
function createPromiseReturnType(func: FunctionLikeDeclaration, promisedType: Type) {
|
||||
const promiseType = createPromiseType(promisedType);
|
||||
if (promiseType === emptyObjectType) {
|
||||
error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type);
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
return promiseType;
|
||||
}
|
||||
|
||||
function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type {
|
||||
const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
|
||||
if (!func.body) {
|
||||
@ -11814,19 +11828,12 @@ namespace ts {
|
||||
else {
|
||||
types = checkAndAggregateReturnExpressionTypes(func, contextualMapper);
|
||||
if (!types) {
|
||||
return neverType;
|
||||
// For an async function, the return type will not be never, but rather a Promise for never.
|
||||
return isAsync ? createPromiseReturnType(func, neverType) : neverType;
|
||||
}
|
||||
if (types.length === 0) {
|
||||
if (isAsync) {
|
||||
// For an async function, the return type will not be void, but rather a Promise for void.
|
||||
const promiseType = createPromiseType(voidType);
|
||||
if (promiseType === emptyObjectType) {
|
||||
error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type);
|
||||
return unknownType;
|
||||
}
|
||||
return promiseType;
|
||||
}
|
||||
return voidType;
|
||||
// For an async function, the return type will not be void, but rather a Promise for void.
|
||||
return isAsync ? createPromiseReturnType(func, voidType) : voidType;
|
||||
}
|
||||
}
|
||||
// When yield/return statements are contextually typed we allow the return type to be a union type.
|
||||
@ -11840,7 +11847,7 @@ namespace ts {
|
||||
else {
|
||||
error(func, Diagnostics.No_best_common_type_exists_among_return_expressions);
|
||||
// Defer to unioning the return types so we get a) downstream errors earlier and b) better Salsa experience
|
||||
return getUnionType(types);
|
||||
return isAsync ? createPromiseReturnType(func, getUnionType(types)) : getUnionType(types);
|
||||
}
|
||||
}
|
||||
|
||||
@ -11853,21 +11860,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
const widenedType = getWidenedType(type);
|
||||
if (isAsync) {
|
||||
// From within an async function you can return either a non-promise value or a promise. Any
|
||||
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
|
||||
// return type of the body is awaited type of the body, wrapped in a native Promise<T> type.
|
||||
const promiseType = createPromiseType(widenedType);
|
||||
if (promiseType === emptyObjectType) {
|
||||
error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type);
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
return promiseType;
|
||||
}
|
||||
else {
|
||||
return widenedType;
|
||||
}
|
||||
// From within an async function you can return either a non-promise value or a promise. Any
|
||||
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
|
||||
// return type of the body is awaited type of the body, wrapped in a native Promise<T> type.
|
||||
return isAsync ? createPromiseReturnType(func, widenedType) : widenedType;
|
||||
}
|
||||
|
||||
function checkAndAggregateYieldOperandTypes(func: FunctionLikeDeclaration, contextualMapper: TypeMapper): Type[] {
|
||||
@ -13896,7 +13892,7 @@ namespace ts {
|
||||
|
||||
function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage) {
|
||||
type = getWidenedType(type);
|
||||
if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) {
|
||||
if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) {
|
||||
if (location) {
|
||||
if (!message) {
|
||||
message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member;
|
||||
@ -13927,12 +13923,15 @@ namespace ts {
|
||||
// }
|
||||
//
|
||||
|
||||
if (promise.flags & TypeFlags.Any) {
|
||||
if (isTypeAny(promise)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if ((promise.flags & TypeFlags.Reference) && (<GenericType>promise).target === tryGetGlobalPromiseType()) {
|
||||
return (<GenericType>promise).typeArguments[0];
|
||||
if (promise.flags & TypeFlags.Reference) {
|
||||
if ((<GenericType>promise).target === tryGetGlobalPromiseType()
|
||||
|| (<GenericType>promise).target === getGlobalPromiseLikeType()) {
|
||||
return (<GenericType>promise).typeArguments[0];
|
||||
}
|
||||
}
|
||||
|
||||
const globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType();
|
||||
@ -13941,17 +13940,17 @@ namespace ts {
|
||||
}
|
||||
|
||||
const thenFunction = getTypeOfPropertyOfType(promise, "then");
|
||||
if (thenFunction && (thenFunction.flags & TypeFlags.Any)) {
|
||||
if (!thenFunction || isTypeAny(thenFunction)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray;
|
||||
const thenSignatures = getSignaturesOfType(thenFunction, SignatureKind.Call);
|
||||
if (thenSignatures.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefined);
|
||||
if (onfulfilledParameterType.flags & TypeFlags.Any) {
|
||||
if (isTypeAny(onfulfilledParameterType)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -13960,12 +13959,11 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const valueParameterType = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature));
|
||||
return valueParameterType;
|
||||
return getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature));
|
||||
}
|
||||
|
||||
function getTypeOfFirstParameterOfSignature(signature: Signature) {
|
||||
return getTypeAtPosition(signature, 0);
|
||||
return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
120
src/lib/es2015.promise.d.ts
vendored
120
src/lib/es2015.promise.d.ts
vendored
@ -3,59 +3,149 @@
|
||||
*/
|
||||
interface Promise<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>): Promise<TResult>;
|
||||
|
||||
/**
|
||||
* Creates a new Promise with the same internal state of this Promise.
|
||||
* @returns A Promise.
|
||||
*/
|
||||
then(): Promise<T>;
|
||||
|
||||
/**
|
||||
* Attaches a callback for only the rejection of the Promise.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
|
||||
catch(onrejected?: (reason: any) => void): Promise<T>;
|
||||
catch<TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>;
|
||||
|
||||
/**
|
||||
* Attaches a callback for only the rejection of the Promise.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
catch(onrejected: (reason: any) => T | PromiseLike<T>): Promise<T>;
|
||||
}
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: Promise<any>;
|
||||
|
||||
/**
|
||||
* Creates a new Promise.
|
||||
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
|
||||
* a resolve callback used resolve the promise with a value or the result of another promise,
|
||||
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
|
||||
* a resolve callback used resolve the promise with a value or the result of another promise,
|
||||
* and a reject callback used to reject the promise with a provided reason or error.
|
||||
*/
|
||||
new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new 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]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<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]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<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]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<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]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<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]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<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]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
* @param reason The reason the promise was rejected.
|
||||
* @returns A new rejected Promise.
|
||||
*/
|
||||
reject(reason: any): Promise<void>;
|
||||
reject(reason: any): Promise<never>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
|
||||
52
src/lib/es5.d.ts
vendored
52
src/lib/es5.d.ts
vendored
@ -1255,13 +1255,33 @@ declare type PromiseConstructorLike = new <T>(executor: (resolve: (value?: T | P
|
||||
|
||||
interface PromiseLike<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
|
||||
/**
|
||||
* Creates a new Promise with the same internal state of this Promise.
|
||||
* @returns A Promise.
|
||||
*/
|
||||
then(): PromiseLike<T>;
|
||||
}
|
||||
|
||||
interface ArrayLike<T> {
|
||||
@ -1524,7 +1544,7 @@ interface Int8Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
@ -1797,7 +1817,7 @@ interface Uint8Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
@ -2071,7 +2091,7 @@ interface Uint8ClampedArray {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
@ -2344,7 +2364,7 @@ interface Int16Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
@ -2618,7 +2638,7 @@ interface Uint16Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
@ -2891,7 +2911,7 @@ interface Int32Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
@ -3164,7 +3184,7 @@ interface Uint32Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
@ -3437,7 +3457,7 @@ interface Float32Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
@ -3711,7 +3731,7 @@ interface Float64Array {
|
||||
* Returns the index of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user