Adds 'promised' type to better handle promise resolution and await

This commit is contained in:
Ron Buckton
2017-07-10 13:51:38 -07:00
parent f888c88f31
commit ebaa253deb
59 changed files with 2376 additions and 977 deletions
+1 -1
View File
@@ -1032,7 +1032,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are:
const fileMatcher = cmdLineOptions["files"];
const files = fileMatcher
? `src/**/${fileMatcher}`
: "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
: "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts' --exclude 'src/lib/es2015.iterable.d.ts' --exclude 'src/lib/es2015.promise.d.ts'";
const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`;
console.log("Linting: " + cmd);
child_process.execSync(cmd, { stdio: [0, 1, 2] });
+1 -1
View File
@@ -1208,7 +1208,7 @@ task("lint", ["build-rules"], () => {
const fileMatcher = process.env.f || process.env.file || process.env.files;
const files = fileMatcher
? `src/**/${fileMatcher}`
: "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
: "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts' --exclude 'src/lib/es2015.iterable.d.ts' --exclude 'src/lib/es2015.promise.d.ts'";
const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`;
console.log("Linting: " + cmd);
jake.exec([cmd], { interactive: true }, () => {
+233 -68
View File
@@ -310,6 +310,7 @@ namespace ts {
let deferredGlobalESSymbolType: ObjectType;
let deferredGlobalTypedPropertyDescriptorType: GenericType;
let deferredGlobalPromiseType: GenericType;
let deferredGlobalPromiseLikeType: GenericType;
let deferredGlobalPromiseConstructorSymbol: Symbol;
let deferredGlobalPromiseConstructorLikeType: ObjectType;
let deferredGlobalIterableType: GenericType;
@@ -350,7 +351,7 @@ namespace ts {
const visitedFlowTypes: FlowType[] = [];
const potentialThisCollisions: Node[] = [];
const potentialNewTargetCollisions: Node[] = [];
const awaitedTypeStack: number[] = [];
const promisedTypeStack: Type[] = [];
const diagnostics = createDiagnosticCollection();
@@ -2490,13 +2491,18 @@ namespace ts {
if (type.flags & TypeFlags.Index) {
const indexedType = (<IndexType>type).type;
const indexTypeNode = typeToTypeNodeHelper(indexedType, context);
return createTypeOperatorNode(indexTypeNode);
return createTypeOperatorNode(indexTypeNode, SyntaxKind.KeyOfKeyword);
}
if (type.flags & TypeFlags.IndexedAccess) {
const objectTypeNode = typeToTypeNodeHelper((<IndexedAccessType>type).objectType, context);
const indexTypeNode = typeToTypeNodeHelper((<IndexedAccessType>type).indexType, context);
return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode);
}
if (type.flags & TypeFlags.Promised) {
const indexedType = (<PromisedType>type).type;
const indexTypeNode = typeToTypeNodeHelper(indexedType, context);
return createTypeOperatorNode(indexTypeNode, SyntaxKind.PromisedKeyword);
}
Debug.fail("Should be unreachable.");
@@ -3264,6 +3270,17 @@ namespace ts {
writeType((<IndexedAccessType>type).indexType, TypeFormatFlags.None);
writePunctuation(writer, SyntaxKind.CloseBracketToken);
}
else if (type.flags & TypeFlags.Promised) {
if (flags & TypeFormatFlags.InElementType) {
writePunctuation(writer, SyntaxKind.OpenParenToken);
}
writer.writeKeyword("promised");
writeSpace(writer);
writeType((<PromisedType>type).type, TypeFormatFlags.InElementType);
if (flags & TypeFormatFlags.InElementType) {
writePunctuation(writer, SyntaxKind.CloseParenToken);
}
}
else {
// Should never get here
// { ... }
@@ -5680,7 +5697,8 @@ namespace ts {
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T'
const templateReadonly = !!type.declaration.readonlyToken;
const templateOptional = !!type.declaration.questionToken;
if (type.declaration.typeParameter.constraint.kind === SyntaxKind.TypeOperator) {
const constraintDeclaration = type.declaration.typeParameter.constraint;
if (constraintDeclaration.kind === SyntaxKind.TypeOperator && (<TypeOperatorNode>constraintDeclaration).operator === SyntaxKind.KeyOfKeyword) {
// We have a { [P in keyof T]: X }
for (const propertySymbol of getPropertiesOfType(modifiersType)) {
addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol);
@@ -5694,7 +5712,8 @@ namespace ts {
// if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X.
// Finally, iterate over the constituents of the resulting iteration type.
const keyType = constraintType.flags & TypeFlags.TypeVariable ? getApparentType(constraintType) : constraintType;
const iterationType = keyType.flags & TypeFlags.Index ? getIndexType(getApparentType((<IndexType>keyType).type)) : keyType;
const iterationType = keyType.flags & TypeFlags.Index ? getIndexType(getApparentType((<IndexType>keyType).type)) :
keyType.flags & TypeFlags.Promised ? getPromisedType(getApparentType((<PromisedType>keyType).type)) : keyType;
forEachType(iterationType, addMemberForKeyType);
}
setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined);
@@ -5747,7 +5766,7 @@ namespace ts {
function getModifiersTypeFromMappedType(type: MappedType) {
if (!type.modifiersType) {
const constraintDeclaration = type.declaration.typeParameter.constraint;
if (constraintDeclaration.kind === SyntaxKind.TypeOperator) {
if (constraintDeclaration.kind === SyntaxKind.TypeOperator && (<TypeOperatorNode>constraintDeclaration).operator === SyntaxKind.KeyOfKeyword) {
// If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check
// AST nodes here because, when T is a non-generic type, the logic below eagerly resolves
// 'keyof T' to a literal union type and we can't recover T from that type.
@@ -5769,7 +5788,7 @@ namespace ts {
function isGenericMappedType(type: Type) {
if (getObjectFlags(type) & ObjectFlags.Mapped) {
const constraintType = getConstraintTypeFromMappedType(<MappedType>type);
return maybeTypeOfKind(constraintType, TypeFlags.TypeVariable | TypeFlags.Index);
return maybeTypeOfKind(constraintType, TypeFlags.TypeVariable | TypeFlags.Index | TypeFlags.Promised);
}
return false;
}
@@ -7018,6 +7037,10 @@ namespace ts {
return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise" as __String, /*arity*/ 1, reportErrors)) || emptyGenericType;
}
function getGlobalPromiseLikeType(reportErrors: boolean) {
return deferredGlobalPromiseLikeType || (deferredGlobalPromiseLikeType = getGlobalType("PromiseLike" as __String, /*arity*/ 1, reportErrors)) || emptyGenericType;
}
function getGlobalPromiseConstructorSymbol(reportErrors: boolean): Symbol | undefined {
return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise" as __String, reportErrors));
}
@@ -7481,7 +7504,15 @@ namespace ts {
function getTypeFromTypeOperatorNode(node: TypeOperatorNode) {
const links = getNodeLinks(node);
if (!links.resolvedType) {
links.resolvedType = getIndexType(getTypeFromTypeNode(node.type));
const type = getTypeFromTypeNode(node.type);
switch (node.operator) {
case SyntaxKind.KeyOfKeyword:
links.resolvedType = getIndexType(type);
break;
case SyntaxKind.PromisedKeyword:
links.resolvedType = getPromisedType(type) || unknownType;
break;
}
}
return links.resolvedType;
}
@@ -8273,6 +8304,9 @@ namespace ts {
if (type.flags & TypeFlags.IndexedAccess) {
return getIndexedAccessType(instantiateType((<IndexedAccessType>type).objectType, mapper), instantiateType((<IndexedAccessType>type).indexType, mapper));
}
if (type.flags & TypeFlags.Promised) {
return getPromisedType(instantiateType((<IndexType>type).type, mapper)) || unknownType;
}
return type;
}
@@ -9192,6 +9226,22 @@ namespace ts {
}
}
}
else if (target.flags & TypeFlags.Promised) {
// A promised S is related to a promised T if S is related to T
if (source.flags & TypeFlags.Promised) {
if (result = isRelatedTo((<PromisedType>source).type, (<PromisedType>target).type, /*reportErrors*/ false)) {
return result;
}
}
// A type S is related to promised T if S is related to promised C, where C is the
// constraint of T.
const constraint = getConstraintOfType((<PromisedType>target).type);
if (constraint) {
if (result = isRelatedTo(source, getPromisedType(constraint), reportErrors)) {
return result;
}
}
}
if (source.flags & TypeFlags.TypeParameter) {
// A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X.
@@ -9239,6 +9289,16 @@ namespace ts {
}
}
}
else if (source.flags & TypeFlags.Promised) {
// A promised S is related to T if promised C is related to T, where C is the
// constraint of S.
const constraint = getConstraintOfType((<PromisedType>source).type);
if (constraint) {
if (result = isRelatedTo(getPromisedType(constraint), target, reportErrors)) {
return result;
}
}
}
else {
if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
// We have type references to same target type, see if relationship holds for all type arguments
@@ -12731,7 +12791,7 @@ namespace ts {
const contextualReturnType = getContextualReturnType(func);
return functionFlags & FunctionFlags.Async
? contextualReturnType && getAwaitedTypeOfPromise(contextualReturnType) // Async function
? contextualReturnType && getPromisedTypeOfPromise(contextualReturnType) // Async function
: contextualReturnType; // Regular function
}
return undefined;
@@ -16385,7 +16445,7 @@ namespace ts {
const globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true);
if (globalPromiseType !== emptyGenericType) {
// if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type
promisedType = getAwaitedType(promisedType) || emptyObjectType;
promisedType = getPromisedType(promisedType) || emptyObjectType;
return createTypeReference(<GenericType>globalPromiseType, [promisedType]);
}
@@ -16424,7 +16484,7 @@ namespace ts {
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
// return type of the body should be unwrapped to its awaited type, which we will wrap in
// the native Promise<T> type later in this function.
type = checkAwaitedType(type, /*errorNode*/ func, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
type = checkPromisedType(type, /*errorNode*/ func, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
}
}
else {
@@ -16499,7 +16559,7 @@ namespace ts {
type = checkIteratedTypeOrElementType(type, yieldExpression.expression, /*allowStringInput*/ false, (functionFlags & FunctionFlags.Async) !== 0);
}
if (functionFlags & FunctionFlags.Async) {
type = checkAwaitedType(type, expr, yieldExpression.asteriskToken
type = checkPromisedType(type, expr, yieldExpression.asteriskToken
? Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
: Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
}
@@ -16552,7 +16612,7 @@ namespace ts {
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
// return type of the body should be unwrapped to its awaited type, which should be wrapped in
// the native Promise<T> type by the caller.
type = checkAwaitedType(type, func, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
type = checkPromisedType(type, func, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
}
if (type.flags & TypeFlags.Never) {
hasReturnOfTypeNever = true;
@@ -16728,7 +16788,7 @@ namespace ts {
const exprType = checkExpression(<Expression>node.body);
if (returnOrPromisedType) {
if ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async) { // Async function
const awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
const awaitedType = checkPromisedType(exprType, node.body, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body);
}
else { // Normal function
@@ -16845,7 +16905,7 @@ namespace ts {
}
const operandType = checkExpression(node.expression);
return checkAwaitedType(operandType, node, Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
return checkPromisedType(operandType, node, Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
}
function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type {
@@ -17499,7 +17559,7 @@ namespace ts {
if (nodeIsYieldStar) {
checkTypeAssignableTo(
functionFlags & FunctionFlags.Async
? getAwaitedType(expressionElementType, node.expression, Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)
? getPromisedType(expressionElementType, node.expression, Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)
: expressionElementType,
signatureElementType,
node.expression,
@@ -17508,7 +17568,7 @@ namespace ts {
else {
checkTypeAssignableTo(
functionFlags & FunctionFlags.Async
? getAwaitedType(expressionType, node.expression, Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)
? getPromisedType(expressionType, node.expression, Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)
: expressionType,
signatureElementType,
node.expression,
@@ -18859,19 +18919,18 @@ namespace ts {
}
}
function getAwaitedTypeOfPromise(type: Type, errorNode?: Node, diagnosticMessage?: DiagnosticMessage): Type | undefined {
const promisedType = getPromisedTypeOfPromise(type, errorNode);
return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage);
}
/**
* Gets the "promised type" of a promise.
* @param type The type of the promise.
* @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback.
* Gets the explicit "fulfillment type" of a Promise-like type.
*
* The "fulfillment type" of a type is the type of the "value" parameter of the
* "onfulfilled" callback. This function **does not** recursively unwrap the
* "fulfillment type".
*
* If the type is not Promise-like, `undefined` is returned.
*/
function getPromisedTypeOfPromise(promise: Type, errorNode?: Node): Type {
function getFulfillmentTypeOfPromise(type: Type, errorNode?: Node): Type | undefined {
//
// { // promise
// { // type
// then( // thenFunction
// onfulfilled: ( // onfulfilledParameterType
// value: T // valueParameterType
@@ -18880,20 +18939,21 @@ namespace ts {
// }
//
if (isTypeAny(promise)) {
if (isTypeAny(type)) {
return undefined;
}
const typeAsPromise = <PromiseOrAwaitableType>promise;
if (typeAsPromise.promisedTypeOfPromise) {
return typeAsPromise.promisedTypeOfPromise;
const typeAsPromise = <PromiseOrAwaitableType>type;
if (typeAsPromise.fulfillmentType) {
return typeAsPromise.fulfillmentType;
}
if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) {
return typeAsPromise.promisedTypeOfPromise = (<GenericType>promise).typeArguments[0];
if (isReferenceToType(type, getGlobalPromiseType(/*reportErrors*/ false)) ||
isReferenceToType(type, getGlobalPromiseLikeType(/*reportErrors*/ false))) {
return typeAsPromise.fulfillmentType = (<GenericType>type).typeArguments[0];
}
const thenFunction = getTypeOfPropertyOfType(promise, "then" as __String);
const thenFunction = getTypeOfPropertyOfType(type, "then" as __String);
if (isTypeAny(thenFunction)) {
return undefined;
}
@@ -18919,50 +18979,103 @@ namespace ts {
return undefined;
}
return typeAsPromise.promisedTypeOfPromise = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), /*subtypeReduction*/ true);
return typeAsPromise.fulfillmentType = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), /*subtypeReduction*/ true);
}
/**
* Gets the "awaited type" of a type.
* @param type The type to await.
* @remarks The "awaited type" of an expression is its "promised type" if the expression is a
* Promise-like type; otherwise, it is the type of the expression. This is used to reflect
* The runtime behavior of the `await` keyword.
* Gets or creates a `promised T` type for a type variable.
*
* The "promised type" of a type variable cannot be determined until it is instantiated. As
* a result, a `PromisedType` for the type variable is created that can be instantiated
* or related later.
*/
function checkAwaitedType(type: Type, errorNode: Node, diagnosticMessage: DiagnosticMessage): Type {
return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType;
function getPromisedTypeForGenericType(type: TypeVariable | UnionOrIntersectionType) {
if (!type.resolvedPromisedType) {
type.resolvedPromisedType = <PromisedType>createType(TypeFlags.Promised);
type.resolvedPromisedType.type = type;
}
return type.resolvedPromisedType;
}
function getAwaitedType(type: Type, errorNode?: Node, diagnosticMessage?: DiagnosticMessage): Type | undefined {
/**
* Gets the "promised type" of a type.
*
* The "promised type" of an expression is its "fulfillment type" if the expression is a
* Promise-like type; otherwise, it is the type of the expression. If the "fulfillment
* type" is itself a Promise-like, the "fulfillment type" is recursively unwrapped until a
* non-promise type is found.
*
* This is used to reflect the runtime behavior of the `await` keyword and the `promised T`
* type.
*/
function getPromisedType(type: Type): Type | undefined;
/**
* Gets the "promised type" of a type.
*
* The "promised type" of an expression is its "fulfillment type" if the expression is a
* Promise-like type; otherwise, it is the type of the expression. If the "fulfillment
* type" is itself a Promise-like, the "fulfillment type" is recursively unwrapped until a
* non-promise type is found.
*
* This is used to reflect the runtime behavior of the `await` keyword and the `promised T`
* type.
*/
function getPromisedType(type: Type, errorNode: Node, diagnosticMessage: DiagnosticMessage): Type | undefined;
/**
* Gets the "promised type" of a type.
*
* The "promised type" of an expression is its "fulfillment type" if the expression is a
* Promise-like type; otherwise, it is the type of the expression. If the "fulfillment
* type" is itself a Promise-like, the "fulfillment type" is recursively unwrapped until a
* non-promise type is found.
*
* This is used to reflect the runtime behavior of the `await` keyword and the `promised T`
* type.
*/
function getPromisedType(type: Type, errorNode?: Node, diagnosticMessage?: DiagnosticMessage): Type | undefined {
// We cannot resolve the promised type for a type variable until it is instantiated. As
// such, we create a `promised T` type that can either be instantiated or related later.
if (isTypeOfKind(type, TypeFlags.TypeVariable)) {
// We don't use `maybeTypeOfKind` here as we want to try to reduce a Union that mixes
// type variables and non-type variables so that we don't end up with types like:
// 'promised (Promise<never> | T)' when we could end up with `promised T`
return getPromisedTypeForGenericType(<TypeVariable | UnionOrIntersectionType>type);
}
const typeAsAwaitable = <PromiseOrAwaitableType>type;
if (typeAsAwaitable.awaitedTypeOfType) {
return typeAsAwaitable.awaitedTypeOfType;
// Use the cached type if already computed.
if (typeAsAwaitable.promisedType) {
return typeAsAwaitable.promisedType;
}
// Use the `any` type if the type is `any`.
if (isTypeAny(type)) {
return typeAsAwaitable.awaitedTypeOfType = type;
return type;
}
// For a union, get a union of the promised types of each constituent.
if (type.flags & TypeFlags.Union) {
let types: Type[];
for (const constituentType of (<UnionType>type).types) {
types = append(types, getAwaitedType(constituentType, errorNode, diagnosticMessage));
types = append(types, getPromisedType(constituentType, errorNode, diagnosticMessage));
}
// if no promised types could be resolved for any constituents, return undefined.
if (!types) {
return undefined;
}
return typeAsAwaitable.awaitedTypeOfType = getUnionType(types, /*subtypeReduction*/ true);
return typeAsAwaitable.promisedType = getUnionType(types, /*subtypeReduction*/ true);
}
const promisedType = getPromisedTypeOfPromise(type);
if (promisedType) {
if (type.id === promisedType.id || indexOf(awaitedTypeStack, promisedType.id) >= 0) {
const fulfillmentType = getFulfillmentTypeOfPromise(type);
if (fulfillmentType) {
if (type === fulfillmentType || promisedTypeStack.lastIndexOf(fulfillmentType) >= 0) {
// Verify that we don't have a bad actor in the form of a promise whose
// promised type is the same as the promise type, or a mutually recursive
// promise. If so, we return undefined as we cannot guess the shape. If this
// were the actual case in the JavaScript, this Promise would never resolve.
// "fulfillment type" is the same as the promise, or a mutually recursive
// promise. If so, we return `undefined` as we cannot guess the shape. If this
// were the actual case in the JavaScript, this promise would never resolve.
//
// An example of a bad actor with a singly-recursive promise type might
// be:
@@ -18972,7 +19085,8 @@ namespace ts {
// onfulfilled: (value: BadPromise) => any,
// onrejected: (error: any) => any): BadPromise;
// }
// The above interface will pass the PromiseLike check, and return a
//
// The above interface will pass the PromiseLike check and return a
// promised type of `BadPromise`. Since this is a self reference, we
// don't want to keep recursing ad infinitum.
//
@@ -18999,21 +19113,21 @@ namespace ts {
// Keep track of the type we're about to unwrap to avoid bad recursive promise types.
// See the comments above for more information.
awaitedTypeStack.push(type.id);
const awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage);
awaitedTypeStack.pop();
promisedTypeStack.push(type);
const promisedType = getPromisedType(fulfillmentType, errorNode, diagnosticMessage);
promisedTypeStack.pop();
if (!awaitedType) {
if (!promisedType) {
return undefined;
}
return typeAsAwaitable.awaitedTypeOfType = awaitedType;
return typeAsAwaitable.promisedType = promisedType;
}
// The type was not a promise, so it could not be unwrapped any further.
// As long as the type does not have a callable "then" property, it is
// safe to return the type; otherwise, an error will be reported in
// the call to getNonThenableType and we will return undefined.
// the call to `getNonThenableType` and we will return `undefined`.
//
// An example of a non-promise "thenable" might be:
//
@@ -19024,17 +19138,68 @@ namespace ts {
// will never settle. We treat this as an error to help flag an early indicator
// of a runtime problem. If the user wants to return this value from an async
// function, they would need to wrap it in some other value. If they want it to
// be treated as a promise, they can cast to <any>.
// be treated as a promise, they can cast to `any`.
const thenFunction = getTypeOfPropertyOfType(type, "then" as __String);
if (thenFunction && getSignaturesOfType(thenFunction, SignatureKind.Call).length > 0) {
if (errorNode) {
Debug.assert(!!diagnosticMessage);
error(errorNode, diagnosticMessage);
}
return undefined;
}
return typeAsAwaitable.awaitedTypeOfType = type;
return typeAsAwaitable.promisedType = type;
}
/**
* Checks the "promised type" of a type.
*
* The "promised type" of an expression is its "fulfillment type" if the expression is a
* Promise-like type; otherwise, it is the type of the expression. If the "fulfillment
* type" is itself a Promise-like, the "fulfillment type" is recursively unwrapped until a
* non-promise type is found.
*
* If `type` is not Promise-like, `type` is returned.
* If the "promised type" of `type` is a non-promise "thenable", `unknownType` is returned.
*/
function checkPromisedType(type: Type, errorNode: Node, diagnosticMessage: DiagnosticMessage): Type {
return getPromisedType(type, errorNode, diagnosticMessage) || unknownType;
}
/**
* Gets the "promised type" of a Promise-like type.
*
* The "promised type" of an expression is its "fulfillment type" if the expression is a
* Promise-like type; otherwise, it is the type of the expression. If the "fulfillment
* type" is itself a Promise-like, the "fulfillment type" is recursively unwrapped until a
* non-promise type is found.
*
* If `type` is not Promise-like, `undefined` is returned.
*/
function getPromisedTypeOfPromise(type: Type): Type | undefined;
/**
* Gets the "promised type" of a Promise-like type.
*
* The "promised type" of an expression is its "fulfillment type" if the expression is a
* Promise-like type; otherwise, it is the type of the expression. If the "fulfillment
* type" is itself a Promise-like, the "fulfillment type" is recursively unwrapped until a
* non-promise type is found.
*
* If `type` is not Promise-like, `undefined` is returned.
*/
function getPromisedTypeOfPromise(type: Type, errorNode: Node, diagnosticMessage: DiagnosticMessage): Type | undefined;
/**
* Gets the "promised type" of a Promise-like type.
*
* The "promised type" of an expression is its "fulfillment type" if the expression is a
* Promise-like type; otherwise, it is the type of the expression. If the "fulfillment
* type" is itself a Promise-like, the "fulfillment type" is recursively unwrapped until a
* non-promise type is found.
*
* If `type` is not Promise-like, `undefined` is returned.
*/
function getPromisedTypeOfPromise(type: Type, errorNode?: Node, diagnosticMessage?: DiagnosticMessage): Type | undefined {
const promisedType = getFulfillmentTypeOfPromise(type, errorNode);
return promisedType && getPromisedType(promisedType, errorNode, diagnosticMessage);
}
/**
@@ -19141,7 +19306,7 @@ namespace ts {
}
// Get and return the awaited type of the return type.
return checkAwaitedType(returnType, node, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
return checkPromisedType(returnType, node, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
}
/** Check a decorator */
@@ -20484,7 +20649,7 @@ namespace ts {
// For an async iterator, we must get the awaited type of the return type.
if (isAsyncIterator) {
nextResult = getAwaitedTypeOfPromise(nextResult, errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property);
nextResult = getPromisedTypeOfPromise(nextResult, errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property);
if (isTypeAny(nextResult)) {
return undefined;
}
@@ -20534,7 +20699,7 @@ namespace ts {
function isUnwrappedReturnTypeVoidOrAny(func: FunctionLike, returnType: Type): boolean {
const unwrappedReturnType = (getFunctionFlags(func) & FunctionFlags.AsyncGenerator) === FunctionFlags.Async
? getPromisedTypeOfPromise(returnType) // Async function
? getFulfillmentTypeOfPromise(returnType) // Async function
: returnType; // AsyncGenerator function, Generator function, or normal function
return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.Any);
}
@@ -20575,8 +20740,8 @@ namespace ts {
}
else if (getEffectiveReturnTypeNode(func) || isGetAccessorWithAnnotatedSetAccessor(func)) {
if (functionFlags & FunctionFlags.Async) { // Async function
const promisedType = getPromisedTypeOfPromise(returnType);
const awaitedType = checkAwaitedType(exprType, node, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
const promisedType = getFulfillmentTypeOfPromise(returnType);
const awaitedType = checkPromisedType(exprType, node, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
if (promisedType) {
// If the function has a return type, but promisedType is
// undefined, an error will be reported in checkAsyncFunctionReturnType
+3 -3
View File
@@ -627,15 +627,15 @@ namespace ts {
return <ThisTypeNode>createSynthesizedNode(SyntaxKind.ThisType);
}
export function createTypeOperatorNode(type: TypeNode) {
export function createTypeOperatorNode(type: TypeNode, operator: SyntaxKind.KeyOfKeyword | SyntaxKind.PromisedKeyword) {
const node = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode;
node.operator = SyntaxKind.KeyOfKeyword;
node.operator = operator;
node.type = parenthesizeElementTypeMember(type);
return node;
}
export function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode) {
return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node;
return node.type !== type ? updateNode(createTypeOperatorNode(type, node.operator), node) : node;
}
export function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode) {
+5 -3
View File
@@ -2663,7 +2663,7 @@ namespace ts {
return type;
}
function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword) {
function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.PromisedKeyword) {
const node = <TypeOperatorNode>createNode(SyntaxKind.TypeOperator);
parseExpected(operator);
node.operator = operator;
@@ -2672,9 +2672,11 @@ namespace ts {
}
function parseTypeOperatorOrHigher(): TypeNode {
switch (token()) {
const keyword = token();
switch (keyword) {
case SyntaxKind.KeyOfKeyword:
return parseTypeOperator(SyntaxKind.KeyOfKeyword);
case SyntaxKind.PromisedKeyword:
return parseTypeOperator(keyword);
}
return parseArrayTypeOrHigher();
}
+1
View File
@@ -104,6 +104,7 @@ namespace ts {
"package": SyntaxKind.PackageKeyword,
"private": SyntaxKind.PrivateKeyword,
"protected": SyntaxKind.ProtectedKeyword,
"promised": SyntaxKind.PromisedKeyword,
"public": SyntaxKind.PublicKeyword,
"readonly": SyntaxKind.ReadonlyKeyword,
"require": SyntaxKind.RequireKeyword,
+22 -12
View File
@@ -192,6 +192,7 @@ namespace ts {
ModuleKeyword,
NamespaceKeyword,
NeverKeyword,
PromisedKeyword,
ReadonlyKeyword,
RequireKeyword,
NumberKeyword,
@@ -986,7 +987,7 @@ namespace ts {
export interface TypeOperatorNode extends TypeNode {
kind: SyntaxKind.TypeOperator;
operator: SyntaxKind.KeyOfKeyword;
operator: SyntaxKind.KeyOfKeyword | SyntaxKind.PromisedKeyword;
type: TypeNode;
}
@@ -3157,17 +3158,18 @@ namespace ts {
Intersection = 1 << 17, // Intersection (T & U)
Index = 1 << 18, // keyof T
IndexedAccess = 1 << 19, // T[K]
Promised = 1 << 20, // promised T
/* @internal */
FreshLiteral = 1 << 20, // Fresh literal type
FreshLiteral = 1 << 21, // Fresh literal type
/* @internal */
ContainsWideningType = 1 << 21, // Type is or contains undefined or null widening type
ContainsWideningType = 1 << 22, // Type is or contains undefined or null widening type
/* @internal */
ContainsObjectLiteral = 1 << 22, // Type is or contains object literal type
ContainsObjectLiteral = 1 << 23, // Type is or contains object literal type
/* @internal */
ContainsAnyFunctionType = 1 << 23, // Type is or contains object literal type
NonPrimitive = 1 << 24, // intrinsic object type
ContainsAnyFunctionType = 1 << 24, // Type is or contains object literal type
NonPrimitive = 1 << 25, // intrinsic object type
/* @internal */
JsxAttributes = 1 << 25, // Jsx attributes type
JsxAttributes = 1 << 26, // Jsx attributes type
/* @internal */
Nullable = Undefined | Null,
@@ -3186,12 +3188,12 @@ namespace ts {
EnumLike = Enum | EnumLiteral,
UnionOrIntersection = Union | Intersection,
StructuredType = Object | Union | Intersection,
StructuredOrTypeVariable = StructuredType | TypeParameter | Index | IndexedAccess,
StructuredOrTypeVariable = StructuredType | TypeParameter | Index | IndexedAccess | Promised,
TypeVariable = TypeParameter | IndexedAccess,
// 'Narrowable' types are types where narrowing actually narrows.
// This *should* be every type other than null, undefined, void, and never
Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | NonPrimitive,
Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | NonPrimitive | Promised,
NotUnionOrUnit = Any | ESSymbol | Object | NonPrimitive,
/* @internal */
RequiresWidening = ContainsWideningType | ContainsObjectLiteral,
@@ -3313,6 +3315,8 @@ namespace ts {
resolvedBaseConstraint: Type;
/* @internal */
couldContainTypeVariables: boolean;
/* @internal */
resolvedPromisedType: PromisedType;
}
export interface UnionType extends UnionOrIntersectionType { }
@@ -3376,9 +3380,8 @@ namespace ts {
/* @internal */
export interface PromiseOrAwaitableType extends ObjectType, UnionType {
promiseTypeOfPromiseConstructor?: Type;
promisedTypeOfPromise?: Type;
awaitedTypeOfType?: Type;
fulfillmentType?: Type; // Type of `value` parameter of `onfulfilled` callback.
promisedType?: Type; // The "fulfillment type" if a Promise-like, otherwise this type.
}
export interface TypeVariable extends Type {
@@ -3386,6 +3389,8 @@ namespace ts {
resolvedBaseConstraint: Type;
/* @internal */
resolvedIndexType: IndexType;
/* @internal */
resolvedPromisedType: PromisedType;
}
// Type parameters (TypeFlags.TypeParameter)
@@ -3415,6 +3420,11 @@ namespace ts {
type: TypeVariable | UnionOrIntersectionType;
}
// promised T types (TypeFlags.Promised)
export interface PromisedType extends Type {
type: TypeVariable;
}
export const enum SignatureKind {
Call,
Construct,
+2 -2
View File
@@ -197,7 +197,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
all<TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>;
all<TAll>(values: Iterable<TAll>): Promise<(promised TAll)[]>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -205,7 +205,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T>(values: Iterable<T | PromiseLike<T>>): Promise<T>;
race<T>(values: Iterable<T>): Promise<promised T>;
}
declare namespace Reflect {
+22 -22
View File
@@ -18,7 +18,7 @@ interface PromiseConstructor {
* @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]>;
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8, promised T9, promised T10]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
@@ -26,7 +26,7 @@ interface PromiseConstructor {
* @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]>;
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8, promised T9]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
@@ -34,7 +34,7 @@ interface PromiseConstructor {
* @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]>;
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1, T2, T3, T4, T5, T6, T7, T8]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
@@ -42,7 +42,7 @@ interface PromiseConstructor {
* @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]>;
all<T1, T2, T3, T4, T5, T6, T7>(values: [T1, T2, T3, T4, T5, T6, T7]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
@@ -50,7 +50,7 @@ interface PromiseConstructor {
* @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]>;
all<T1, T2, T3, T4, T5, T6>(values: [T1, T2, T3, T4, T5, T6]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
@@ -58,7 +58,7 @@ interface PromiseConstructor {
* @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]>;
all<T1, T2, T3, T4, T5>(values: [T1, T2, T3, T4, T5]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
@@ -66,7 +66,7 @@ interface PromiseConstructor {
* @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]>;
all<T1, T2, T3, T4>(values: [T1, T2, T3, T4]): Promise<[promised T1, promised T2, promised T3, promised T4]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
@@ -74,7 +74,7 @@ interface PromiseConstructor {
* @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]>;
all<T1, T2, T3>(values: [T1, T2, T3]): Promise<[promised T1, promised T2, promised T3]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
@@ -82,7 +82,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
all<T1, T2>(values: [T1, T2]): Promise<[promised T1, promised T2]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
@@ -90,7 +90,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>;
all<T>(values: T[]): Promise<(promised T)[]>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -98,7 +98,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<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>;
race<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]): Promise<promised T1 | promised T2 | promised T3 | promised T4 | promised T5 | promised T6 | promised T7 | promised T8 | promised T9 | promised T10>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -106,7 +106,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<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>;
race<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9]): Promise<promised T1 | promised T2 | promised T3 | promised T4 | promised T5 | promised T6 | promised T7 | promised T8 | promised T9>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -114,7 +114,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<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>;
race<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1, T2, T3, T4, T5, T6, T7, T8]): Promise<promised T1 | promised T2 | promised T3 | promised T4 | promised T5 | promised T6 | promised T7 | promised T8>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -122,7 +122,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<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>;
race<T1, T2, T3, T4, T5, T6, T7>(values: [T1, T2, T3, T4, T5, T6, T7]): Promise<promised T1 | promised T2 | promised T3 | promised T4 | promised T5 | promised T6 | promised T7>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -130,7 +130,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<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>;
race<T1, T2, T3, T4, T5, T6>(values: [T1, T2, T3, T4, T5, T6]): Promise<promised T1 | promised T2 | promised T3 | promised T4 | promised T5 | promised T6>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -138,7 +138,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<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>;
race<T1, T2, T3, T4, T5>(values: [T1, T2, T3, T4, T5]): Promise<promised T1 | promised T2 | promised T3 | promised T4 | promised T5>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -146,7 +146,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<T1 | T2 | T3 | T4>;
race<T1, T2, T3, T4>(values: [T1, T2, T3, T4]): Promise<promised T1 | promised T2 | promised T3 | promised T4>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -154,7 +154,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<T1 | T2 | T3>;
race<T1, T2, T3>(values: [T1, T2, T3]): Promise<promised T1 | promised T2 | promised T3>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -162,7 +162,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<T1 | T2>;
race<T1, T2>(values: [T1, T2]): Promise<promised T1 | promised T2>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
@@ -170,7 +170,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T>(values: (T | PromiseLike<T>)[]): Promise<T>;
race<T>(values: T[]): Promise<promised T>;
/**
* Creates a new rejected promise for the provided reason.
@@ -184,14 +184,14 @@ interface PromiseConstructor {
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject<T>(reason: any): Promise<T>;
reject<T>(reason: any): Promise<promised T>;
/**
* Creates a new resolved promise for the provided value.
* @param value A promise.
* @returns A promise whose internal state matches the provided promise.
*/
resolve<T>(value: T | PromiseLike<T>): Promise<T>;
resolve<T>(value: T): Promise<promised T>;
/**
* Creates a new resolved promise .
+3 -3
View File
@@ -1259,7 +1259,7 @@ interface PromiseLike<T> {
* @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 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>;
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: promised T) => TResult1) | undefined | null, onrejected?: ((reason: any) => TResult2) | undefined | null): PromiseLike<promised TResult1 | promised TResult2>;
}
/**
@@ -1272,14 +1272,14 @@ interface Promise<T> {
* @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 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: promised T) => TResult1) | undefined | null, onrejected?: ((reason: any) => TResult2) | undefined | null): Promise<promised TResult1 | promised TResult2>;
/**
* 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<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
catch<TResult = never>(onrejected?: ((reason: any) => TResult) | undefined | null): Promise<promised T | promised TResult>;
}
interface ArrayLike<T> {
@@ -6,9 +6,9 @@ class C {
>method : () => void
var fn = async () => await this;
>fn : () => Promise<this>
>async () => await this : () => Promise<this>
>await this : this
>fn : () => Promise<promised this>
>async () => await this : () => Promise<promised this>
>await this : promised this
>this : this
}
}
@@ -6,9 +6,9 @@ class C {
>method : () => void
var fn = async () => await this;
>fn : () => Promise<this>
>async () => await this : () => Promise<this>
>await this : this
>fn : () => Promise<promised this>
>async () => await this : () => Promise<promised this>
>await this : promised this
>this : this
}
}
@@ -6,9 +6,9 @@ class C {
>method : () => void
var fn = async () => await this;
>fn : () => Promise<this>
>async () => await this : () => Promise<this>
>await this : this
>fn : () => Promise<promised this>
>async () => await this : () => Promise<promised this>
>await this : promised this
>this : this
}
}
@@ -6,8 +6,8 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
Type 'Thenable' is not assignable to type 'PromiseLike<T>'.
Types of property 'then' are incompatible.
Type '() => void' is not assignable to type '<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'.
Type 'void' is not assignable to type 'PromiseLike<TResult1 | TResult2>'.
Type '() => void' is not assignable to type '<TResult1 = T, TResult2 = never>(onfulfilled?: (value: promised T) => TResult1, onrejected?: (reason: any) => TResult2) => PromiseLike<promised TResult1 | promised TResult2>'.
Type 'void' is not assignable to type 'PromiseLike<promised TResult1 | promised TResult2>'.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(17,16): error TS1058: The return type of an async function must either be a valid promise or must not contain a callable 'then' member.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(23,25): error TS1320: Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.
@@ -37,8 +37,8 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
!!! error TS1055: Type 'Thenable' is not assignable to type 'PromiseLike<T>'.
!!! error TS1055: Types of property 'then' are incompatible.
!!! error TS1055: Type '() => void' is not assignable to type '<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'.
!!! error TS1055: Type 'void' is not assignable to type 'PromiseLike<TResult1 | TResult2>'.
!!! error TS1055: Type '() => void' is not assignable to type '<TResult1 = T, TResult2 = never>(onfulfilled?: (value: promised T) => TResult1, onrejected?: (reason: any) => TResult2) => PromiseLike<promised TResult1 | promised TResult2>'.
!!! error TS1055: Type 'void' is not assignable to type 'PromiseLike<promised TResult1 | promised TResult2>'.
async function fn7() { return; } // valid: Promise<void>
async function fn8() { return 1; } // valid: Promise<number>
async function fn9() { return null; } // valid: Promise<any>
@@ -53,9 +53,9 @@ async function fIndexedTypeForPromiseOfStringProp(obj: Obj): Promise<Obj["string
return Promise.resolve(obj.stringProp);
>Promise.resolve(obj.stringProp) : Promise<string>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>obj.stringProp : string
>obj : Obj
>stringProp : string
@@ -70,9 +70,9 @@ async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise<Obj
return Promise.resolve<Obj["stringProp"]>(obj.stringProp);
>Promise.resolve<Obj["stringProp"]>(obj.stringProp) : Promise<string>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Obj : Obj
>obj.stringProp : string
>obj : Obj
@@ -101,9 +101,9 @@ async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]
return Promise.resolve(obj.anyProp);
>Promise.resolve(obj.anyProp) : Promise<any>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>obj.anyProp : any
>obj : Obj
>anyProp : any
@@ -118,9 +118,9 @@ async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise<Obj["a
return Promise.resolve<Obj["anyProp"]>(obj.anyProp);
>Promise.resolve<Obj["anyProp"]>(obj.anyProp) : Promise<any>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Obj : Obj
>obj.anyProp : any
>obj : Obj
@@ -153,9 +153,9 @@ async function fGenericIndexedTypeForPromiseOfStringProp<TObj extends Obj>(obj:
return Promise.resolve(obj.stringProp);
>Promise.resolve(obj.stringProp) : Promise<string>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>obj.stringProp : string
>obj : TObj
>stringProp : string
@@ -171,10 +171,10 @@ async function fGenericIndexedTypeForExplicitPromiseOfStringProp<TObj extends Ob
>TObj : TObj
return Promise.resolve<TObj["stringProp"]>(obj.stringProp);
>Promise.resolve<TObj["stringProp"]>(obj.stringProp) : Promise<TObj["stringProp"]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve<TObj["stringProp"]>(obj.stringProp) : Promise<promised TObj["stringProp"]>
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>TObj : TObj
>obj.stringProp : string
>obj : TObj
@@ -207,9 +207,9 @@ async function fGenericIndexedTypeForPromiseOfAnyProp<TObj extends Obj>(obj: TOb
return Promise.resolve(obj.anyProp);
>Promise.resolve(obj.anyProp) : Promise<any>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>obj.anyProp : any
>obj : TObj
>anyProp : any
@@ -225,10 +225,10 @@ async function fGenericIndexedTypeForExplicitPromiseOfAnyProp<TObj extends Obj>(
>TObj : TObj
return Promise.resolve<TObj["anyProp"]>(obj.anyProp);
>Promise.resolve<TObj["anyProp"]>(obj.anyProp) : Promise<TObj["anyProp"]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve<TObj["anyProp"]>(obj.anyProp) : Promise<promised TObj["anyProp"]>
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>TObj : TObj
>obj.anyProp : any
>obj : TObj
@@ -270,10 +270,10 @@ async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends
>K : K
return Promise.resolve(obj[key]);
>Promise.resolve(obj[key]) : Promise<TObj[K]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve(obj[key]) : Promise<promised TObj[K]>
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>obj[key] : TObj[K]
>obj : TObj
>key : K
@@ -294,10 +294,10 @@ async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K
>K : K
return Promise.resolve<TObj[K]>(obj[key]);
>Promise.resolve<TObj[K]>(obj[key]) : Promise<TObj[K]>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve<TObj[K]>(obj[key]) : Promise<promised TObj[K]>
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>TObj : TObj
>K : K
>obj[key] : TObj[K]
@@ -39,9 +39,9 @@ async function countEverything(): Promise<number> {
>resultB : B[]
>await Promise.all([ providerA(), providerB(), ]) : [A[], B[]]
>Promise.all([ providerA(), providerB(), ]) : Promise<[A[], B[]]>
>Promise.all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <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[]>; }
>Promise.all : { <TAll>(values: Iterable<TAll>): Promise<promised TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8, promised T9, promised T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8, promised T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1, T2, T3, T4, T5, T6, T7, T8]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1, T2, T3, T4, T5, T6, T7]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1, T2, T3, T4, T5, T6]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6]>; <T1, T2, T3, T4, T5>(values: [T1, T2, T3, T4, T5]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5]>; <T1, T2, T3, T4>(values: [T1, T2, T3, T4]): Promise<[promised T1, promised T2, promised T3, promised T4]>; <T1, T2, T3>(values: [T1, T2, T3]): Promise<[promised T1, promised T2, promised T3]>; <T1, T2>(values: [T1, T2]): Promise<[promised T1, promised T2]>; <T>(values: T[]): Promise<promised T[]>; }
>Promise : PromiseConstructor
>all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <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[]>; }
>all : { <TAll>(values: Iterable<TAll>): Promise<promised TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8, promised T9, promised T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8, promised T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1, T2, T3, T4, T5, T6, T7, T8]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1, T2, T3, T4, T5, T6, T7]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1, T2, T3, T4, T5, T6]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6]>; <T1, T2, T3, T4, T5>(values: [T1, T2, T3, T4, T5]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5]>; <T1, T2, T3, T4>(values: [T1, T2, T3, T4]): Promise<[promised T1, promised T2, promised T3, promised T4]>; <T1, T2, T3>(values: [T1, T2, T3]): Promise<[promised T1, promised T2, promised T3]>; <T1, T2>(values: [T1, T2]): Promise<[promised T1, promised T2]>; <T>(values: T[]): Promise<promised T[]>; }
>[ providerA(), providerB(), ] : [Promise<A[]>, Promise<B[]>]
providerA(),
@@ -20,9 +20,9 @@ export default async(() => await(Promise.resolve(1)));
>await(Promise.resolve(1)) : any
>await : (...args: any[]) => any
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
=== tests/cases/compiler/b.ts ===
@@ -15,9 +15,9 @@ var p1 = import("./0");
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -15,9 +15,9 @@ function foo(x: Promise<any>) {
x.then(value => {
>x.then(value => { let b = new value.B(); b.print(); }) : Promise<void>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x : Promise<any>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>value => { let b = new value.B(); b.print(); } : (value: any) => void
>value : any
@@ -33,11 +33,11 @@ class C {
this.myModule.then(Zero => {
>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise<void>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>this.myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>this : this
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -15,9 +15,9 @@ var p1 = import("./0");
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -15,9 +15,9 @@ var p1 = import("./0");
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -15,9 +15,9 @@ var p1 = import("./0");
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -15,9 +15,9 @@ var p1 = import("./0");
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -15,9 +15,9 @@ var p1 = import("./0");
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -16,9 +16,9 @@ function foo(x: Promise<any>) {
x.then(value => {
>x.then(value => { let b = new value.B(); b.print(); }) : Promise<void>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x : Promise<any>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>value => { let b = new value.B(); b.print(); } : (value: any) => void
>value : any
@@ -33,11 +33,11 @@ class C {
this.myModule.then(Zero => {
>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise<void>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>this.myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>this : this
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -15,9 +15,9 @@ var p1 = import("./0");
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -16,9 +16,9 @@ function foo(x: Promise<any>) {
x.then(value => {
>x.then(value => { let b = new value.B(); b.print(); }) : Promise<void>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x : Promise<any>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>value => { let b = new value.B(); b.print(); } : (value: any) => void
>value : any
@@ -33,11 +33,11 @@ class C {
this.myModule.then(Zero => {
>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise<void>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>this.myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>this : this
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -15,9 +15,9 @@ var p1 = import("./0");
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -16,9 +16,9 @@ function foo(x: Promise<any>) {
x.then(value => {
>x.then(value => { let b = new value.B(); b.print(); }) : Promise<void>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x : Promise<any>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>value => { let b = new value.B(); b.print(); } : (value: any) => void
>value : any
@@ -33,11 +33,11 @@ class C {
this.myModule.then(Zero => {
>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise<void>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>this.myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>this : this
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -15,9 +15,9 @@ var p1 = import("./0");
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -16,9 +16,9 @@ function foo(x: Promise<any>) {
x.then(value => {
>x.then(value => { let b = new value.B(); b.print(); }) : Promise<void>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x : Promise<any>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>value => { let b = new value.B(); b.print(); } : (value: any) => void
>value : any
@@ -33,11 +33,11 @@ class C {
this.myModule.then(Zero => {
>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise<void>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>this.myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>this : this
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
@@ -69,9 +69,9 @@ const p2 = import(whatToLoad ? getSpecifier() : "defaulPath") as Promise<typeof
p1.then(zero => {
>p1.then(zero => { return zero.foo(); // ok, zero is any}) : Promise<any>
>p1.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p1 : Promise<any>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>zero => { return zero.foo(); // ok, zero is any} : (zero: any) => any
>zero : any
@@ -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 : <TResult1 = void, TResult2 = never>(onfulfilled?: (value: void) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.doStuff(order.id) .then : <TResult1 = void, TResult2 = never>(onfulfilled?: (value: void) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>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 : <TResult1 = void, TResult2 = never>(onfulfilled?: (value: void) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = void, TResult2 = never>(onfulfilled?: (value: void) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>(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 : <TResult1 = {}[], TResult2 = never>(onfulfilled?: (value: {}[]) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>Promise.all(result.map(populateItems)) .then : <TResult1 = {}[], TResult2 = never>(onfulfilled?: (value: {}[]) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>Promise.all(result.map(populateItems)) : Promise<{}[]>
>Promise.all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <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[]>; }
>Promise.all : { <TAll>(values: Iterable<TAll>): Promise<promised TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8, promised T9, promised T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8, promised T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1, T2, T3, T4, T5, T6, T7, T8]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1, T2, T3, T4, T5, T6, T7]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1, T2, T3, T4, T5, T6]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6]>; <T1, T2, T3, T4, T5>(values: [T1, T2, T3, T4, T5]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5]>; <T1, T2, T3, T4>(values: [T1, T2, T3, T4]): Promise<[promised T1, promised T2, promised T3, promised T4]>; <T1, T2, T3>(values: [T1, T2, T3]): Promise<[promised T1, promised T2, promised T3]>; <T1, T2>(values: [T1, T2]): Promise<[promised T1, promised T2]>; <T>(values: T[]): Promise<promised T[]>; }
>Promise : PromiseConstructor
>all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <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[]>; }
>all : { <TAll>(values: Iterable<TAll>): Promise<promised TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8, promised T9, promised T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1, T2, T3, T4, T5, T6, T7, T8, T9]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8, promised T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1, T2, T3, T4, T5, T6, T7, T8]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7, promised T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1, T2, T3, T4, T5, T6, T7]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6, promised T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1, T2, T3, T4, T5, T6]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5, promised T6]>; <T1, T2, T3, T4, T5>(values: [T1, T2, T3, T4, T5]): Promise<[promised T1, promised T2, promised T3, promised T4, promised T5]>; <T1, T2, T3, T4>(values: [T1, T2, T3, T4]): Promise<[promised T1, promised T2, promised T3, promised T4]>; <T1, T2, T3>(values: [T1, T2, T3]): Promise<[promised T1, promised T2, promised T3]>; <T1, T2>(values: [T1, T2]): Promise<[promised T1, promised T2]>; <T>(values: T[]): Promise<promised T[]>; }
>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 : <TResult1 = {}[], TResult2 = never>(onfulfilled?: (value: {}[]) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = {}[], TResult2 = never>(onfulfilled?: (value: {}[]) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>(orders: Array<MyModule.MyModel>) => { resolve(orders); } : (orders: MyModule.MyModel[]) => void
>orders : MyModule.MyModel[]
>Array : T[]
@@ -147,10 +147,10 @@ declare var console: any;
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>out().then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>out() : Promise<{}>
>out : () => Promise<{}>
>then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>() => { console.log("Yea!");} : () => void
console.log("Yea!");
@@ -147,10 +147,10 @@ declare var console: any;
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>out().then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>out() : Promise<{}>
>out : () => Promise<{}>
>then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>() => { console.log("Yea!");} : () => void
console.log("Yea!");
@@ -147,10 +147,10 @@ declare var console: any;
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>out().then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>out() : Promise<{}>
>out : () => Promise<{}>
>then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>() => { console.log("Yea!");} : () => void
console.log("Yea!");
@@ -15,8 +15,8 @@ async function test(isError: boolean = false) {
>x : string
>await Promise.resolve("The test is passed without an error.") : string
>Promise.resolve("The test is passed without an error.") : Promise<string>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>"The test is passed without an error." : "The test is passed without an error."
}
@@ -49,7 +49,7 @@ tests/cases/compiler/promisePermutations.ts(144,35): error TS2345: Argument of t
tests/cases/compiler/promisePermutations.ts(152,36): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
Types of property 'then' are incompatible.
Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
@@ -64,7 +64,7 @@ tests/cases/compiler/promisePermutations.ts(159,21): error TS2345: Argument of t
tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
Type 'Promise<number>' is not assignable to type 'IPromise<string>'.
Types of property 'then' are incompatible.
Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
Types of parameters 'onfulfilled' and 'success' are incompatible.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
@@ -303,7 +303,7 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
@@ -330,7 +330,7 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
!!! error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
!!! error TS2345: Type 'Promise<number>' is not assignable to type 'IPromise<string>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
!!! error TS2345: Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
!!! error TS2345: Types of parameters 'onfulfilled' and 'success' are incompatible.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
@@ -49,7 +49,7 @@ tests/cases/compiler/promisePermutations2.ts(143,35): error TS2345: Argument of
tests/cases/compiler/promisePermutations2.ts(151,36): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
Types of property 'then' are incompatible.
Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
@@ -64,7 +64,7 @@ tests/cases/compiler/promisePermutations2.ts(158,21): error TS2345: Argument of
tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
Type 'Promise<number>' is not assignable to type 'IPromise<string>'.
Types of property 'then' are incompatible.
Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
Types of parameters 'onfulfilled' and 'success' are incompatible.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
@@ -302,7 +302,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
@@ -329,7 +329,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
!!! error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
!!! error TS2345: Type 'Promise<number>' is not assignable to type 'IPromise<string>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
!!! error TS2345: Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
!!! error TS2345: Types of parameters 'onfulfilled' and 'success' are incompatible.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
@@ -52,7 +52,7 @@ tests/cases/compiler/promisePermutations3.ts(143,35): error TS2345: Argument of
tests/cases/compiler/promisePermutations3.ts(151,36): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
Types of property 'then' are incompatible.
Type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
@@ -67,14 +67,14 @@ tests/cases/compiler/promisePermutations3.ts(158,21): error TS2345: Argument of
tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
Type 'Promise<number>' is not assignable to type 'IPromise<string>'.
Types of property 'then' are incompatible.
Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>'.
Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>'.
Types of parameters 'onfulfilled' and 'success' are incompatible.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<any>'.
Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
Types of property 'then' are incompatible.
Type '<U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: any) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Type '<U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: any) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
@@ -314,7 +314,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
@@ -341,7 +341,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
!!! error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
!!! error TS2345: Type 'Promise<number>' is not assignable to type 'IPromise<string>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>'.
!!! error TS2345: Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>'.
!!! error TS2345: Types of parameters 'onfulfilled' and 'success' are incompatible.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
@@ -355,6 +355,6 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
!!! error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<any>'.
!!! error TS2345: Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '<U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: any) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Type '<U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: any) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok
+4 -4
View File
@@ -4,7 +4,7 @@ interface Promise<T> {
>T : T
then<A>(success?: (value: T) => Promise<A>): Promise<A>;
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <A>(success?: (value: T) => Promise<A>): Promise<A>; <B>(success?: (value: T) => B): Promise<B>; }
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: promised T) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <A>(success?: (value: T) => Promise<A>): Promise<A>; <B>(success?: (value: T) => B): Promise<B>; }
>A : A
>success : (value: T) => Promise<A>
>value : T
@@ -15,7 +15,7 @@ interface Promise<T> {
>A : A
then<B>(success?: (value: T) => B): Promise<B>;
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <A>(success?: (value: T) => Promise<A>): Promise<A>; <B>(success?: (value: T) => B): Promise<B>; }
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: promised T) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <A>(success?: (value: T) => Promise<A>): Promise<A>; <B>(success?: (value: T) => B): Promise<B>; }
>B : B
>success : (value: T) => B
>value : T
@@ -37,9 +37,9 @@ var p: Promise<number> = null;
var p2 = p.then(function (x) {
>p2 : Promise<number>
>p.then(function (x) { return p;} ) : Promise<number>
>p.then : { <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <A>(success?: (value: number) => Promise<A>): Promise<A>; <B>(success?: (value: number) => B): Promise<B>; }
>p.then : { <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <A>(success?: (value: number) => Promise<A>): Promise<A>; <B>(success?: (value: number) => B): Promise<B>; }
>p : Promise<number>
>then : { <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <A>(success?: (value: number) => Promise<A>): Promise<A>; <B>(success?: (value: number) => B): Promise<B>; }
>then : { <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <A>(success?: (value: number) => Promise<A>): Promise<A>; <B>(success?: (value: number) => B): Promise<B>; }
>function (x) { return p;} : (x: number) => Promise<number>
>x : number
File diff suppressed because it is too large Load Diff
@@ -1,31 +0,0 @@
tests/cases/compiler/promiseTypeInference.ts(10,34): error TS2345: Argument of type '(s: string) => IPromise<number>' is not assignable to parameter of type '(value: string) => number | PromiseLike<number>'.
Type 'IPromise<number>' is not assignable to type 'number | PromiseLike<number>'.
Type 'IPromise<number>' is not assignable to type 'PromiseLike<number>'.
Types of property 'then' are incompatible.
Type '<U>(success?: (value: number) => IPromise<U>) => IPromise<U>' is not assignable to type '<TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
Type 'TResult1 | PromiseLike<TResult1>' is not assignable to type 'IPromise<TResult1 | TResult2>'.
Type 'TResult1' is not assignable to type 'IPromise<TResult1 | TResult2>'.
==== tests/cases/compiler/promiseTypeInference.ts (1 errors) ====
declare class Promise<T> {
then<U>(success?: (value: T) => Promise<U>): Promise<U>;
}
interface IPromise<T> {
then<U>(success?: (value: T) => IPromise<U>): IPromise<U>;
}
declare function load(name: string): Promise<string>;
declare function convert(s: string): IPromise<number>;
var $$x = load("something").then(s => convert(s));
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(s: string) => IPromise<number>' is not assignable to parameter of type '(value: string) => number | PromiseLike<number>'.
!!! error TS2345: Type 'IPromise<number>' is not assignable to type 'number | PromiseLike<number>'.
!!! error TS2345: Type 'IPromise<number>' is not assignable to type 'PromiseLike<number>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '<U>(success?: (value: number) => IPromise<U>) => IPromise<U>' is not assignable to type '<TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'.
!!! error TS2345: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2345: Type 'TResult1 | PromiseLike<TResult1>' is not assignable to type 'IPromise<TResult1 | TResult2>'.
!!! error TS2345: Type 'TResult1' is not assignable to type 'IPromise<TResult1 | TResult2>'.
@@ -4,7 +4,7 @@ declare class Promise<T> {
>T : T
then<U>(success?: (value: T) => Promise<U>): Promise<U>;
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: T) => Promise<U>): Promise<U>; }
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: promised T) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: T) => Promise<U>): Promise<U>; }
>U : U
>success : (value: T) => Promise<U>
>value : T
@@ -42,11 +42,11 @@ declare function convert(s: string): IPromise<number>;
var $$x = load("something").then(s => convert(s));
>$$x : Promise<number>
>load("something").then(s => convert(s)) : Promise<number>
>load("something").then : { <TResult1 = string, TResult2 = never>(onfulfilled?: (value: string) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: string) => Promise<U>): Promise<U>; }
>load("something").then : { <TResult1 = string, TResult2 = never>(onfulfilled?: (value: string) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: string) => Promise<U>): Promise<U>; }
>load("something") : Promise<string>
>load : (name: string) => Promise<string>
>"something" : "something"
>then : { <TResult1 = string, TResult2 = never>(onfulfilled?: (value: string) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: string) => Promise<U>): Promise<U>; }
>then : { <TResult1 = string, TResult2 = never>(onfulfilled?: (value: string) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: string) => Promise<U>): Promise<U>; }
>s => convert(s) : (s: string) => IPromise<number>
>s : string
>convert(s) : IPromise<number>
File diff suppressed because it is too large Load Diff
@@ -27,9 +27,9 @@ function f1(): Promise<T1> {
return Promise.resolve({ __t1: "foo_t1" });
>Promise.resolve({ __t1: "foo_t1" }) : Promise<{ __t1: string; }>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>{ __t1: "foo_t1" } : { __t1: string; }
>__t1 : string
>"foo_t1" : "foo_t1"
@@ -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 : <TResult1 = T2, TResult2 = never>(onfulfilled?: (value: T2) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>f1() .then(f2, (e: Error) => { throw e;}) .then : <TResult1 = T2, TResult2 = never>(onfulfilled?: (value: T2) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f1() .then(f2, (e: Error) => { throw e;}) : Promise<T2>
>f1() .then : <TResult1 = T1, TResult2 = never>(onfulfilled?: (value: T1) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>f1() .then : <TResult1 = T1, TResult2 = never>(onfulfilled?: (value: T1) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f1() : Promise<T1>
>f1 : () => Promise<T1>
.then(f2, (e: Error) => {
>then : <TResult1 = T1, TResult2 = never>(onfulfilled?: (value: T1) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = T1, TResult2 = never>(onfulfilled?: (value: T1) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f2 : (x: T1) => T2
>(e: Error) => { throw e;} : (e: Error) => never
>e : Error
@@ -72,7 +72,7 @@ var x3 = f1()
})
.then((x: T2) => {
>then : <TResult1 = T2, TResult2 = never>(onfulfilled?: (value: T2) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>then : <TResult1 = T2, TResult2 = never>(onfulfilled?: (value: T2) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>(x: T2) => { return { __t3: x.__t2 + "bar" };} : (x: T2) => { __t3: string; }
>x : T2
>T2 : T2
+208
View File
@@ -0,0 +1,208 @@
//// [promised.ts]
// simple
declare const p0: Promise<number>;
p0.then(x => x);
declare const p1: Promise<Promise<number>>;
p1.then(x => x);
declare const p2: Promise<number | Promise<number>>;
p2.then(x => x);
// generics
declare const f: boolean;
declare function makePromise<T>(x: T): Promise<T>;
makePromise(1).then(x => x);
makePromise("a").then(x => x);
makePromise({ a: 1 }).then(x => x);
makePromise(f ? 1 : "a").then(x => x);
function f0<U>(u: U) {
return makePromise(u).then(x => x);
}
f0(1).then(x => x);
f0("a").then(x => x);
f0(f ? 1 : "a").then(x => x);
f0(makePromise(1)).then(x => x);
function f1<U, V>(u: U, v: V) {
return makePromise(u).then(x => {
if (f) return x;
return makePromise(v).then(x => x);
});
}
f1(1, "a").then(x => x);
f1(makePromise(1), makePromise("a")).then(x => x);
function f2<U>(u: U) {
return makePromise(u).then(x => {
if (f) return x;
return Promise.reject("b");
});
}
f2(1).then(x => x);
f2(makePromise(1)).then(x => x);
function f3<U, V>(u: U, v: V) {
return makePromise(u).catch(x => v);
}
f3(1, "a").then(x => x);
f3(makePromise(1), makePromise("a")).then(x => x);
function f4<U, V>(u: U, v: V) {
return makePromise(u).catch(x => {
if (f) return v;
return Promise.reject("b");
});
}
f4(1, "a").then(x => x);
f4(makePromise(1), makePromise("a")).then(x => x);
async function f5<U>(u: Promise<U>) {
return await u;
}
f5(makePromise(1)).then(x => x);
f5(makePromise(makePromise(1))).then(x => x);
async function f6<U>(u: Promise<Promise<U>>) {
return await u;
}
// assignability
let v0: number;
let v1: promised number;
let v2: promised Promise<number>;
v0 = v1;
v0 = v2;
v1 = v0;
v1 = v2;
v2 = v0;
v2 = v1;
function f7<U>() {
let v0: promised U;
let v1: promised Promise<U>;
v0 = v1;
v1 = v0;
}
async function f8<U>() {
let pu: Promise<U>;
let v0: promised U;
let v1: promised Promise<U>;
v0 = await pu;
v1 = await pu;
}
//// [promised.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());
});
};
p0.then(x => x);
p1.then(x => x);
p2.then(x => x);
makePromise(1).then(x => x);
makePromise("a").then(x => x);
makePromise({ a: 1 }).then(x => x);
makePromise(f ? 1 : "a").then(x => x);
function f0(u) {
return makePromise(u).then(x => x);
}
f0(1).then(x => x);
f0("a").then(x => x);
f0(f ? 1 : "a").then(x => x);
f0(makePromise(1)).then(x => x);
function f1(u, v) {
return makePromise(u).then(x => {
if (f)
return x;
return makePromise(v).then(x => x);
});
}
f1(1, "a").then(x => x);
f1(makePromise(1), makePromise("a")).then(x => x);
function f2(u) {
return makePromise(u).then(x => {
if (f)
return x;
return Promise.reject("b");
});
}
f2(1).then(x => x);
f2(makePromise(1)).then(x => x);
function f3(u, v) {
return makePromise(u).catch(x => v);
}
f3(1, "a").then(x => x);
f3(makePromise(1), makePromise("a")).then(x => x);
function f4(u, v) {
return makePromise(u).catch(x => {
if (f)
return v;
return Promise.reject("b");
});
}
f4(1, "a").then(x => x);
f4(makePromise(1), makePromise("a")).then(x => x);
function f5(u) {
return __awaiter(this, void 0, void 0, function* () {
return yield u;
});
}
f5(makePromise(1)).then(x => x);
f5(makePromise(makePromise(1))).then(x => x);
function f6(u) {
return __awaiter(this, void 0, void 0, function* () {
return yield u;
});
}
// assignability
let v0;
let v1;
let v2;
v0 = v1;
v0 = v2;
v1 = v0;
v1 = v2;
v2 = v0;
v2 = v1;
function f7() {
let v0;
let v1;
v0 = v1;
v1 = v0;
}
function f8() {
return __awaiter(this, void 0, void 0, function* () {
let pu;
let v0;
let v1;
v0 = yield pu;
v1 = yield pu;
});
}
//// [promised.d.ts]
declare const p0: Promise<number>;
declare const p1: Promise<Promise<number>>;
declare const p2: Promise<number | Promise<number>>;
declare const f: boolean;
declare function makePromise<T>(x: T): Promise<T>;
declare function f0<U>(u: U): Promise<promised U>;
declare function f1<U, V>(u: U, v: V): Promise<(promised U) | (promised V)>;
declare function f2<U>(u: U): Promise<promised U>;
declare function f3<U, V>(u: U, v: V): Promise<(promised U) | (promised V)>;
declare function f4<U, V>(u: U, v: V): Promise<(promised U) | (promised V)>;
declare function f5<U>(u: Promise<U>): Promise<promised U>;
declare function f6<U>(u: Promise<Promise<U>>): Promise<promised U>;
declare let v0: number;
declare let v1: promised number;
declare let v2: promised Promise<number>;
declare function f7<U>(): void;
declare function f8<U>(): Promise<void>;
+406
View File
@@ -0,0 +1,406 @@
=== tests/cases/conformance/types/promised/promised.ts ===
// simple
declare const p0: Promise<number>;
>p0 : Symbol(p0, Decl(promised.ts, 1, 13))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
p0.then(x => x);
>p0.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>p0 : Symbol(p0, Decl(promised.ts, 1, 13))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 2, 8))
>x : Symbol(x, Decl(promised.ts, 2, 8))
declare const p1: Promise<Promise<number>>;
>p1 : Symbol(p1, Decl(promised.ts, 4, 13))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
p1.then(x => x);
>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>p1 : Symbol(p1, Decl(promised.ts, 4, 13))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 5, 8))
>x : Symbol(x, Decl(promised.ts, 5, 8))
declare const p2: Promise<number | Promise<number>>;
>p2 : Symbol(p2, Decl(promised.ts, 7, 13))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
p2.then(x => x);
>p2.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>p2 : Symbol(p2, Decl(promised.ts, 7, 13))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 8, 8))
>x : Symbol(x, Decl(promised.ts, 8, 8))
// generics
declare const f: boolean;
>f : Symbol(f, Decl(promised.ts, 11, 13))
declare function makePromise<T>(x: T): Promise<T>;
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>T : Symbol(T, Decl(promised.ts, 12, 29))
>x : Symbol(x, Decl(promised.ts, 12, 32))
>T : Symbol(T, Decl(promised.ts, 12, 29))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>T : Symbol(T, Decl(promised.ts, 12, 29))
makePromise(1).then(x => x);
>makePromise(1).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 13, 20))
>x : Symbol(x, Decl(promised.ts, 13, 20))
makePromise("a").then(x => x);
>makePromise("a").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 14, 22))
>x : Symbol(x, Decl(promised.ts, 14, 22))
makePromise({ a: 1 }).then(x => x);
>makePromise({ a: 1 }).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>a : Symbol(a, Decl(promised.ts, 15, 13))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 15, 27))
>x : Symbol(x, Decl(promised.ts, 15, 27))
makePromise(f ? 1 : "a").then(x => x);
>makePromise(f ? 1 : "a").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>f : Symbol(f, Decl(promised.ts, 11, 13))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 16, 30))
>x : Symbol(x, Decl(promised.ts, 16, 30))
function f0<U>(u: U) {
>f0 : Symbol(f0, Decl(promised.ts, 16, 38))
>U : Symbol(U, Decl(promised.ts, 18, 12))
>u : Symbol(u, Decl(promised.ts, 18, 15))
>U : Symbol(U, Decl(promised.ts, 18, 12))
return makePromise(u).then(x => x);
>makePromise(u).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>u : Symbol(u, Decl(promised.ts, 18, 15))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 19, 31))
>x : Symbol(x, Decl(promised.ts, 19, 31))
}
f0(1).then(x => x);
>f0(1).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f0 : Symbol(f0, Decl(promised.ts, 16, 38))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 21, 11))
>x : Symbol(x, Decl(promised.ts, 21, 11))
f0("a").then(x => x);
>f0("a").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f0 : Symbol(f0, Decl(promised.ts, 16, 38))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 22, 13))
>x : Symbol(x, Decl(promised.ts, 22, 13))
f0(f ? 1 : "a").then(x => x);
>f0(f ? 1 : "a").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f0 : Symbol(f0, Decl(promised.ts, 16, 38))
>f : Symbol(f, Decl(promised.ts, 11, 13))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 23, 21))
>x : Symbol(x, Decl(promised.ts, 23, 21))
f0(makePromise(1)).then(x => x);
>f0(makePromise(1)).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f0 : Symbol(f0, Decl(promised.ts, 16, 38))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 24, 24))
>x : Symbol(x, Decl(promised.ts, 24, 24))
function f1<U, V>(u: U, v: V) {
>f1 : Symbol(f1, Decl(promised.ts, 24, 32))
>U : Symbol(U, Decl(promised.ts, 26, 12))
>V : Symbol(V, Decl(promised.ts, 26, 14))
>u : Symbol(u, Decl(promised.ts, 26, 18))
>U : Symbol(U, Decl(promised.ts, 26, 12))
>v : Symbol(v, Decl(promised.ts, 26, 23))
>V : Symbol(V, Decl(promised.ts, 26, 14))
return makePromise(u).then(x => {
>makePromise(u).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>u : Symbol(u, Decl(promised.ts, 26, 18))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 27, 31))
if (f) return x;
>f : Symbol(f, Decl(promised.ts, 11, 13))
>x : Symbol(x, Decl(promised.ts, 27, 31))
return makePromise(v).then(x => x);
>makePromise(v).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>v : Symbol(v, Decl(promised.ts, 26, 23))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 29, 35))
>x : Symbol(x, Decl(promised.ts, 29, 35))
});
}
f1(1, "a").then(x => x);
>f1(1, "a").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f1 : Symbol(f1, Decl(promised.ts, 24, 32))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 32, 16))
>x : Symbol(x, Decl(promised.ts, 32, 16))
f1(makePromise(1), makePromise("a")).then(x => x);
>f1(makePromise(1), makePromise("a")).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f1 : Symbol(f1, Decl(promised.ts, 24, 32))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 33, 42))
>x : Symbol(x, Decl(promised.ts, 33, 42))
function f2<U>(u: U) {
>f2 : Symbol(f2, Decl(promised.ts, 33, 50))
>U : Symbol(U, Decl(promised.ts, 35, 12))
>u : Symbol(u, Decl(promised.ts, 35, 15))
>U : Symbol(U, Decl(promised.ts, 35, 12))
return makePromise(u).then(x => {
>makePromise(u).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>u : Symbol(u, Decl(promised.ts, 35, 15))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 36, 31))
if (f) return x;
>f : Symbol(f, Decl(promised.ts, 11, 13))
>x : Symbol(x, Decl(promised.ts, 36, 31))
return Promise.reject("b");
>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
});
}
f2(1).then(x => x);
>f2(1).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f2 : Symbol(f2, Decl(promised.ts, 33, 50))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 41, 11))
>x : Symbol(x, Decl(promised.ts, 41, 11))
f2(makePromise(1)).then(x => x);
>f2(makePromise(1)).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f2 : Symbol(f2, Decl(promised.ts, 33, 50))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 42, 24))
>x : Symbol(x, Decl(promised.ts, 42, 24))
function f3<U, V>(u: U, v: V) {
>f3 : Symbol(f3, Decl(promised.ts, 42, 32))
>U : Symbol(U, Decl(promised.ts, 44, 12))
>V : Symbol(V, Decl(promised.ts, 44, 14))
>u : Symbol(u, Decl(promised.ts, 44, 18))
>U : Symbol(U, Decl(promised.ts, 44, 12))
>v : Symbol(v, Decl(promised.ts, 44, 23))
>V : Symbol(V, Decl(promised.ts, 44, 14))
return makePromise(u).catch(x => v);
>makePromise(u).catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>u : Symbol(u, Decl(promised.ts, 44, 18))
>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 45, 32))
>v : Symbol(v, Decl(promised.ts, 44, 23))
}
f3(1, "a").then(x => x);
>f3(1, "a").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f3 : Symbol(f3, Decl(promised.ts, 42, 32))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 47, 16))
>x : Symbol(x, Decl(promised.ts, 47, 16))
f3(makePromise(1), makePromise("a")).then(x => x);
>f3(makePromise(1), makePromise("a")).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f3 : Symbol(f3, Decl(promised.ts, 42, 32))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 48, 42))
>x : Symbol(x, Decl(promised.ts, 48, 42))
function f4<U, V>(u: U, v: V) {
>f4 : Symbol(f4, Decl(promised.ts, 48, 50))
>U : Symbol(U, Decl(promised.ts, 50, 12))
>V : Symbol(V, Decl(promised.ts, 50, 14))
>u : Symbol(u, Decl(promised.ts, 50, 18))
>U : Symbol(U, Decl(promised.ts, 50, 12))
>v : Symbol(v, Decl(promised.ts, 50, 23))
>V : Symbol(V, Decl(promised.ts, 50, 14))
return makePromise(u).catch(x => {
>makePromise(u).catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>u : Symbol(u, Decl(promised.ts, 50, 18))
>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 51, 32))
if (f) return v;
>f : Symbol(f, Decl(promised.ts, 11, 13))
>v : Symbol(v, Decl(promised.ts, 50, 23))
return Promise.reject("b");
>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
});
}
f4(1, "a").then(x => x);
>f4(1, "a").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f4 : Symbol(f4, Decl(promised.ts, 48, 50))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 56, 16))
>x : Symbol(x, Decl(promised.ts, 56, 16))
f4(makePromise(1), makePromise("a")).then(x => x);
>f4(makePromise(1), makePromise("a")).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f4 : Symbol(f4, Decl(promised.ts, 48, 50))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 57, 42))
>x : Symbol(x, Decl(promised.ts, 57, 42))
async function f5<U>(u: Promise<U>) {
>f5 : Symbol(f5, Decl(promised.ts, 57, 50))
>U : Symbol(U, Decl(promised.ts, 59, 18))
>u : Symbol(u, Decl(promised.ts, 59, 21))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>U : Symbol(U, Decl(promised.ts, 59, 18))
return await u;
>u : Symbol(u, Decl(promised.ts, 59, 21))
}
f5(makePromise(1)).then(x => x);
>f5(makePromise(1)).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f5 : Symbol(f5, Decl(promised.ts, 57, 50))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 62, 24))
>x : Symbol(x, Decl(promised.ts, 62, 24))
f5(makePromise(makePromise(1))).then(x => x);
>f5(makePromise(makePromise(1))).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f5 : Symbol(f5, Decl(promised.ts, 57, 50))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>makePromise : Symbol(makePromise, Decl(promised.ts, 11, 25))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promised.ts, 63, 37))
>x : Symbol(x, Decl(promised.ts, 63, 37))
async function f6<U>(u: Promise<Promise<U>>) {
>f6 : Symbol(f6, Decl(promised.ts, 63, 45))
>U : Symbol(U, Decl(promised.ts, 65, 18))
>u : Symbol(u, Decl(promised.ts, 65, 21))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>U : Symbol(U, Decl(promised.ts, 65, 18))
return await u;
>u : Symbol(u, Decl(promised.ts, 65, 21))
}
// assignability
let v0: number;
>v0 : Symbol(v0, Decl(promised.ts, 70, 3))
let v1: promised number;
>v1 : Symbol(v1, Decl(promised.ts, 71, 3))
let v2: promised Promise<number>;
>v2 : Symbol(v2, Decl(promised.ts, 72, 3))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
v0 = v1;
>v0 : Symbol(v0, Decl(promised.ts, 70, 3))
>v1 : Symbol(v1, Decl(promised.ts, 71, 3))
v0 = v2;
>v0 : Symbol(v0, Decl(promised.ts, 70, 3))
>v2 : Symbol(v2, Decl(promised.ts, 72, 3))
v1 = v0;
>v1 : Symbol(v1, Decl(promised.ts, 71, 3))
>v0 : Symbol(v0, Decl(promised.ts, 70, 3))
v1 = v2;
>v1 : Symbol(v1, Decl(promised.ts, 71, 3))
>v2 : Symbol(v2, Decl(promised.ts, 72, 3))
v2 = v0;
>v2 : Symbol(v2, Decl(promised.ts, 72, 3))
>v0 : Symbol(v0, Decl(promised.ts, 70, 3))
v2 = v1;
>v2 : Symbol(v2, Decl(promised.ts, 72, 3))
>v1 : Symbol(v1, Decl(promised.ts, 71, 3))
function f7<U>() {
>f7 : Symbol(f7, Decl(promised.ts, 78, 8))
>U : Symbol(U, Decl(promised.ts, 80, 12))
let v0: promised U;
>v0 : Symbol(v0, Decl(promised.ts, 81, 7))
>U : Symbol(U, Decl(promised.ts, 80, 12))
let v1: promised Promise<U>;
>v1 : Symbol(v1, Decl(promised.ts, 82, 7))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>U : Symbol(U, Decl(promised.ts, 80, 12))
v0 = v1;
>v0 : Symbol(v0, Decl(promised.ts, 81, 7))
>v1 : Symbol(v1, Decl(promised.ts, 82, 7))
v1 = v0;
>v1 : Symbol(v1, Decl(promised.ts, 82, 7))
>v0 : Symbol(v0, Decl(promised.ts, 81, 7))
}
async function f8<U>() {
>f8 : Symbol(f8, Decl(promised.ts, 85, 1))
>U : Symbol(U, Decl(promised.ts, 87, 18))
let pu: Promise<U>;
>pu : Symbol(pu, Decl(promised.ts, 88, 7))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>U : Symbol(U, Decl(promised.ts, 87, 18))
let v0: promised U;
>v0 : Symbol(v0, Decl(promised.ts, 89, 7))
>U : Symbol(U, Decl(promised.ts, 87, 18))
let v1: promised Promise<U>;
>v1 : Symbol(v1, Decl(promised.ts, 90, 7))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>U : Symbol(U, Decl(promised.ts, 87, 18))
v0 = await pu;
>v0 : Symbol(v0, Decl(promised.ts, 89, 7))
>pu : Symbol(pu, Decl(promised.ts, 88, 7))
v1 = await pu;
>v1 : Symbol(v1, Decl(promised.ts, 90, 7))
>pu : Symbol(pu, Decl(promised.ts, 88, 7))
}
+542
View File
@@ -0,0 +1,542 @@
=== tests/cases/conformance/types/promised/promised.ts ===
// simple
declare const p0: Promise<number>;
>p0 : Promise<number>
>Promise : Promise<T>
p0.then(x => x);
>p0.then(x => x) : Promise<number>
>p0.then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p0 : Promise<number>
>then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: number) => number
>x : number
>x : number
declare const p1: Promise<Promise<number>>;
>p1 : Promise<Promise<number>>
>Promise : Promise<T>
>Promise : Promise<T>
p1.then(x => x);
>p1.then(x => x) : Promise<number>
>p1.then : <TResult1 = Promise<number>, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p1 : Promise<Promise<number>>
>then : <TResult1 = Promise<number>, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: number) => number
>x : number
>x : number
declare const p2: Promise<number | Promise<number>>;
>p2 : Promise<number | Promise<number>>
>Promise : Promise<T>
>Promise : Promise<T>
p2.then(x => x);
>p2.then(x => x) : Promise<number>
>p2.then : <TResult1 = number | Promise<number>, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>p2 : Promise<number | Promise<number>>
>then : <TResult1 = number | Promise<number>, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: number) => number
>x : number
>x : number
// generics
declare const f: boolean;
>f : boolean
declare function makePromise<T>(x: T): Promise<T>;
>makePromise : <T>(x: T) => Promise<T>
>T : T
>x : T
>T : T
>Promise : Promise<T>
>T : T
makePromise(1).then(x => x);
>makePromise(1).then(x => x) : Promise<number>
>makePromise(1).then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>makePromise(1) : Promise<number>
>makePromise : <T>(x: T) => Promise<T>
>1 : 1
>then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: number) => number
>x : number
>x : number
makePromise("a").then(x => x);
>makePromise("a").then(x => x) : Promise<string>
>makePromise("a").then : <TResult1 = string, TResult2 = never>(onfulfilled?: (value: string) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>makePromise("a") : Promise<string>
>makePromise : <T>(x: T) => Promise<T>
>"a" : "a"
>then : <TResult1 = string, TResult2 = never>(onfulfilled?: (value: string) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: string) => string
>x : string
>x : string
makePromise({ a: 1 }).then(x => x);
>makePromise({ a: 1 }).then(x => x) : Promise<{ a: number; }>
>makePromise({ a: 1 }).then : <TResult1 = { a: number; }, TResult2 = never>(onfulfilled?: (value: { a: number; }) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>makePromise({ a: 1 }) : Promise<{ a: number; }>
>makePromise : <T>(x: T) => Promise<T>
>{ a: 1 } : { a: number; }
>a : number
>1 : 1
>then : <TResult1 = { a: number; }, TResult2 = never>(onfulfilled?: (value: { a: number; }) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: { a: number; }) => { a: number; }
>x : { a: number; }
>x : { a: number; }
makePromise(f ? 1 : "a").then(x => x);
>makePromise(f ? 1 : "a").then(x => x) : Promise<string | number>
>makePromise(f ? 1 : "a").then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>makePromise(f ? 1 : "a") : Promise<string | number>
>makePromise : <T>(x: T) => Promise<T>
>f ? 1 : "a" : 1 | "a"
>f : boolean
>1 : 1
>"a" : "a"
>then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: string | number) => string | number
>x : string | number
>x : string | number
function f0<U>(u: U) {
>f0 : <U>(u: U) => Promise<promised U>
>U : U
>u : U
>U : U
return makePromise(u).then(x => x);
>makePromise(u).then(x => x) : Promise<promised U>
>makePromise(u).then : <TResult1 = U, TResult2 = never>(onfulfilled?: (value: promised U) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>makePromise(u) : Promise<U>
>makePromise : <T>(x: T) => Promise<T>
>u : U
>then : <TResult1 = U, TResult2 = never>(onfulfilled?: (value: promised U) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: promised U) => promised U
>x : promised U
>x : promised U
}
f0(1).then(x => x);
>f0(1).then(x => x) : Promise<number>
>f0(1).then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f0(1) : Promise<number>
>f0 : <U>(u: U) => Promise<promised U>
>1 : 1
>then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: number) => number
>x : number
>x : number
f0("a").then(x => x);
>f0("a").then(x => x) : Promise<string>
>f0("a").then : <TResult1 = string, TResult2 = never>(onfulfilled?: (value: string) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f0("a") : Promise<string>
>f0 : <U>(u: U) => Promise<promised U>
>"a" : "a"
>then : <TResult1 = string, TResult2 = never>(onfulfilled?: (value: string) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: string) => string
>x : string
>x : string
f0(f ? 1 : "a").then(x => x);
>f0(f ? 1 : "a").then(x => x) : Promise<string | number>
>f0(f ? 1 : "a").then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f0(f ? 1 : "a") : Promise<string | number>
>f0 : <U>(u: U) => Promise<promised U>
>f ? 1 : "a" : 1 | "a"
>f : boolean
>1 : 1
>"a" : "a"
>then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: string | number) => string | number
>x : string | number
>x : string | number
f0(makePromise(1)).then(x => x);
>f0(makePromise(1)).then(x => x) : Promise<number>
>f0(makePromise(1)).then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f0(makePromise(1)) : Promise<number>
>f0 : <U>(u: U) => Promise<promised U>
>makePromise(1) : Promise<number>
>makePromise : <T>(x: T) => Promise<T>
>1 : 1
>then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: number) => number
>x : number
>x : number
function f1<U, V>(u: U, v: V) {
>f1 : <U, V>(u: U, v: V) => Promise<promised U | promised V>
>U : U
>V : V
>u : U
>U : U
>v : V
>V : V
return makePromise(u).then(x => {
>makePromise(u).then(x => { if (f) return x; return makePromise(v).then(x => x); }) : Promise<promised U | promised V>
>makePromise(u).then : <TResult1 = U, TResult2 = never>(onfulfilled?: (value: promised U) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>makePromise(u) : Promise<U>
>makePromise : <T>(x: T) => Promise<T>
>u : U
>then : <TResult1 = U, TResult2 = never>(onfulfilled?: (value: promised U) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => { if (f) return x; return makePromise(v).then(x => x); } : (x: promised U) => promised U | Promise<promised V>
>x : promised U
if (f) return x;
>f : boolean
>x : promised U
return makePromise(v).then(x => x);
>makePromise(v).then(x => x) : Promise<promised V>
>makePromise(v).then : <TResult1 = V, TResult2 = never>(onfulfilled?: (value: promised V) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>makePromise(v) : Promise<V>
>makePromise : <T>(x: T) => Promise<T>
>v : V
>then : <TResult1 = V, TResult2 = never>(onfulfilled?: (value: promised V) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: promised V) => promised V
>x : promised V
>x : promised V
});
}
f1(1, "a").then(x => x);
>f1(1, "a").then(x => x) : Promise<string | number>
>f1(1, "a").then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f1(1, "a") : Promise<string | number>
>f1 : <U, V>(u: U, v: V) => Promise<promised U | promised V>
>1 : 1
>"a" : "a"
>then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: string | number) => string | number
>x : string | number
>x : string | number
f1(makePromise(1), makePromise("a")).then(x => x);
>f1(makePromise(1), makePromise("a")).then(x => x) : Promise<string | number>
>f1(makePromise(1), makePromise("a")).then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f1(makePromise(1), makePromise("a")) : Promise<string | number>
>f1 : <U, V>(u: U, v: V) => Promise<promised U | promised V>
>makePromise(1) : Promise<number>
>makePromise : <T>(x: T) => Promise<T>
>1 : 1
>makePromise("a") : Promise<string>
>makePromise : <T>(x: T) => Promise<T>
>"a" : "a"
>then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: string | number) => string | number
>x : string | number
>x : string | number
function f2<U>(u: U) {
>f2 : <U>(u: U) => Promise<promised U>
>U : U
>u : U
>U : U
return makePromise(u).then(x => {
>makePromise(u).then(x => { if (f) return x; return Promise.reject("b"); }) : Promise<promised U>
>makePromise(u).then : <TResult1 = U, TResult2 = never>(onfulfilled?: (value: promised U) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>makePromise(u) : Promise<U>
>makePromise : <T>(x: T) => Promise<T>
>u : U
>then : <TResult1 = U, TResult2 = never>(onfulfilled?: (value: promised U) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => { if (f) return x; return Promise.reject("b"); } : (x: promised U) => promised U | Promise<never>
>x : promised U
if (f) return x;
>f : boolean
>x : promised U
return Promise.reject("b");
>Promise.reject("b") : Promise<never>
>Promise.reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<promised T>; }
>Promise : PromiseConstructor
>reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<promised T>; }
>"b" : "b"
});
}
f2(1).then(x => x);
>f2(1).then(x => x) : Promise<number>
>f2(1).then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f2(1) : Promise<number>
>f2 : <U>(u: U) => Promise<promised U>
>1 : 1
>then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: number) => number
>x : number
>x : number
f2(makePromise(1)).then(x => x);
>f2(makePromise(1)).then(x => x) : Promise<number>
>f2(makePromise(1)).then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f2(makePromise(1)) : Promise<number>
>f2 : <U>(u: U) => Promise<promised U>
>makePromise(1) : Promise<number>
>makePromise : <T>(x: T) => Promise<T>
>1 : 1
>then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: number) => number
>x : number
>x : number
function f3<U, V>(u: U, v: V) {
>f3 : <U, V>(u: U, v: V) => Promise<promised U | promised V>
>U : U
>V : V
>u : U
>U : U
>v : V
>V : V
return makePromise(u).catch(x => v);
>makePromise(u).catch(x => v) : Promise<promised U | promised V>
>makePromise(u).catch : <TResult = never>(onrejected?: (reason: any) => TResult) => Promise<promised U | promised TResult>
>makePromise(u) : Promise<U>
>makePromise : <T>(x: T) => Promise<T>
>u : U
>catch : <TResult = never>(onrejected?: (reason: any) => TResult) => Promise<promised U | promised TResult>
>x => v : (x: any) => V
>x : any
>v : V
}
f3(1, "a").then(x => x);
>f3(1, "a").then(x => x) : Promise<string | number>
>f3(1, "a").then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f3(1, "a") : Promise<string | number>
>f3 : <U, V>(u: U, v: V) => Promise<promised U | promised V>
>1 : 1
>"a" : "a"
>then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: string | number) => string | number
>x : string | number
>x : string | number
f3(makePromise(1), makePromise("a")).then(x => x);
>f3(makePromise(1), makePromise("a")).then(x => x) : Promise<string | number>
>f3(makePromise(1), makePromise("a")).then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f3(makePromise(1), makePromise("a")) : Promise<string | number>
>f3 : <U, V>(u: U, v: V) => Promise<promised U | promised V>
>makePromise(1) : Promise<number>
>makePromise : <T>(x: T) => Promise<T>
>1 : 1
>makePromise("a") : Promise<string>
>makePromise : <T>(x: T) => Promise<T>
>"a" : "a"
>then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: string | number) => string | number
>x : string | number
>x : string | number
function f4<U, V>(u: U, v: V) {
>f4 : <U, V>(u: U, v: V) => Promise<promised U | promised V>
>U : U
>V : V
>u : U
>U : U
>v : V
>V : V
return makePromise(u).catch(x => {
>makePromise(u).catch(x => { if (f) return v; return Promise.reject("b"); }) : Promise<promised U | promised V>
>makePromise(u).catch : <TResult = never>(onrejected?: (reason: any) => TResult) => Promise<promised U | promised TResult>
>makePromise(u) : Promise<U>
>makePromise : <T>(x: T) => Promise<T>
>u : U
>catch : <TResult = never>(onrejected?: (reason: any) => TResult) => Promise<promised U | promised TResult>
>x => { if (f) return v; return Promise.reject("b"); } : (x: any) => Promise<never> | V
>x : any
if (f) return v;
>f : boolean
>v : V
return Promise.reject("b");
>Promise.reject("b") : Promise<never>
>Promise.reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<promised T>; }
>Promise : PromiseConstructor
>reject : { (reason: any): Promise<never>; <T>(reason: any): Promise<promised T>; }
>"b" : "b"
});
}
f4(1, "a").then(x => x);
>f4(1, "a").then(x => x) : Promise<string | number>
>f4(1, "a").then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f4(1, "a") : Promise<string | number>
>f4 : <U, V>(u: U, v: V) => Promise<promised U | promised V>
>1 : 1
>"a" : "a"
>then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: string | number) => string | number
>x : string | number
>x : string | number
f4(makePromise(1), makePromise("a")).then(x => x);
>f4(makePromise(1), makePromise("a")).then(x => x) : Promise<string | number>
>f4(makePromise(1), makePromise("a")).then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f4(makePromise(1), makePromise("a")) : Promise<string | number>
>f4 : <U, V>(u: U, v: V) => Promise<promised U | promised V>
>makePromise(1) : Promise<number>
>makePromise : <T>(x: T) => Promise<T>
>1 : 1
>makePromise("a") : Promise<string>
>makePromise : <T>(x: T) => Promise<T>
>"a" : "a"
>then : <TResult1 = string | number, TResult2 = never>(onfulfilled?: (value: string | number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: string | number) => string | number
>x : string | number
>x : string | number
async function f5<U>(u: Promise<U>) {
>f5 : <U>(u: Promise<U>) => Promise<promised U>
>U : U
>u : Promise<U>
>Promise : Promise<T>
>U : U
return await u;
>await u : promised U
>u : Promise<U>
}
f5(makePromise(1)).then(x => x);
>f5(makePromise(1)).then(x => x) : Promise<number>
>f5(makePromise(1)).then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f5(makePromise(1)) : Promise<number>
>f5 : <U>(u: Promise<U>) => Promise<promised U>
>makePromise(1) : Promise<number>
>makePromise : <T>(x: T) => Promise<T>
>1 : 1
>then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: number) => number
>x : number
>x : number
f5(makePromise(makePromise(1))).then(x => x);
>f5(makePromise(makePromise(1))).then(x => x) : Promise<number>
>f5(makePromise(makePromise(1))).then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>f5(makePromise(makePromise(1))) : Promise<number>
>f5 : <U>(u: Promise<U>) => Promise<promised U>
>makePromise(makePromise(1)) : Promise<Promise<number>>
>makePromise : <T>(x: T) => Promise<T>
>makePromise(1) : Promise<number>
>makePromise : <T>(x: T) => Promise<T>
>1 : 1
>then : <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1, onrejected?: (reason: any) => TResult2) => Promise<promised TResult1 | promised TResult2>
>x => x : (x: number) => number
>x : number
>x : number
async function f6<U>(u: Promise<Promise<U>>) {
>f6 : <U>(u: Promise<Promise<U>>) => Promise<promised U>
>U : U
>u : Promise<Promise<U>>
>Promise : Promise<T>
>Promise : Promise<T>
>U : U
return await u;
>await u : promised U
>u : Promise<Promise<U>>
}
// assignability
let v0: number;
>v0 : number
let v1: promised number;
>v1 : number
let v2: promised Promise<number>;
>v2 : number
>Promise : Promise<T>
v0 = v1;
>v0 = v1 : number
>v0 : number
>v1 : number
v0 = v2;
>v0 = v2 : number
>v0 : number
>v2 : number
v1 = v0;
>v1 = v0 : number
>v1 : number
>v0 : number
v1 = v2;
>v1 = v2 : number
>v1 : number
>v2 : number
v2 = v0;
>v2 = v0 : number
>v2 : number
>v0 : number
v2 = v1;
>v2 = v1 : number
>v2 : number
>v1 : number
function f7<U>() {
>f7 : <U>() => void
>U : U
let v0: promised U;
>v0 : promised U
>U : U
let v1: promised Promise<U>;
>v1 : promised U
>Promise : Promise<T>
>U : U
v0 = v1;
>v0 = v1 : promised U
>v0 : promised U
>v1 : promised U
v1 = v0;
>v1 = v0 : promised U
>v1 : promised U
>v0 : promised U
}
async function f8<U>() {
>f8 : <U>() => Promise<void>
>U : U
let pu: Promise<U>;
>pu : Promise<U>
>Promise : Promise<T>
>U : U
let v0: promised U;
>v0 : promised U
>U : U
let v1: promised Promise<U>;
>v1 : promised U
>Promise : Promise<T>
>U : U
v0 = await pu;
>v0 = await pu : promised U
>v0 : promised U
>await pu : promised U
>pu : Promise<U>
v1 = await pu;
>v1 = await pu : promised U
>v1 : promised U
>await pu : promised U
>pu : Promise<U>
}
+2 -2
View File
@@ -4,7 +4,7 @@ interface Promise<T> {
>T : T
then<U>(success?: (value: T) => U): Promise<U>;
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: T) => U): Promise<U>; <U>(success?: (value: T) => Promise<U>): Promise<U>; }
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: promised T) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: T) => U): Promise<U>; <U>(success?: (value: T) => Promise<U>): Promise<U>; }
>U : U
>success : (value: T) => U
>value : T
@@ -14,7 +14,7 @@ interface Promise<T> {
>U : U
then<U>(success?: (value: T) => Promise<U>): Promise<U>;
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: T) => U): Promise<U>; <U>(success?: (value: T) => Promise<U>): Promise<U>; }
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: promised T) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(success?: (value: T) => U): Promise<U>; <U>(success?: (value: T) => Promise<U>): Promise<U>; }
>U : U
>success : (value: T) => Promise<U>
>value : T
@@ -4,7 +4,7 @@ interface Promise<T> {
>T : T
then<U>(value: T): void;
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(value: T): void; }
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: promised T) => TResult1, onrejected?: (reason: any) => TResult2): Promise<promised TResult1 | promised TResult2>; <U>(value: T): void; }
>U : U
>value : T
>T : T
@@ -18,9 +18,9 @@ async function a(): Bluebird<void> {
await Bluebird.resolve(); // -- remove this and it compiles
>await Bluebird.resolve() : void
>Bluebird.resolve() : Promise<void>
>Bluebird.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Bluebird.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Bluebird : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
} catch (error) { }
>error : any
@@ -21,9 +21,9 @@ async function * inferReturnType4() {
yield Promise.resolve(1);
>yield Promise.resolve(1) : any
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
}
async function * inferReturnType5() {
@@ -36,9 +36,9 @@ async function * inferReturnType5() {
yield Promise.resolve(2);
>yield Promise.resolve(2) : any
>Promise.resolve(2) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>2 : 2
}
async function * inferReturnType6() {
@@ -57,9 +57,9 @@ async function * inferReturnType7() {
>yield* [Promise.resolve(1)] : any
>[Promise.resolve(1)] : Promise<number>[]
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
}
async function * inferReturnType8() {
@@ -91,9 +91,9 @@ const assignability2: () => AsyncIterableIterator<number> = async function * ()
yield Promise.resolve(1);
>yield Promise.resolve(1) : any
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
};
@@ -118,9 +118,9 @@ const assignability4: () => AsyncIterableIterator<number> = async function * ()
>yield* [Promise.resolve(1)] : any
>[Promise.resolve(1)] : Promise<number>[]
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
};
@@ -156,9 +156,9 @@ const assignability7: () => AsyncIterable<number> = async function * () {
yield Promise.resolve(1);
>yield Promise.resolve(1) : any
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
};
@@ -183,9 +183,9 @@ const assignability9: () => AsyncIterable<number> = async function * () {
>yield* [Promise.resolve(1)] : any
>[Promise.resolve(1)] : Promise<number>[]
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
};
@@ -221,9 +221,9 @@ const assignability12: () => AsyncIterator<number> = async function * () {
yield Promise.resolve(1);
>yield Promise.resolve(1) : any
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
};
@@ -248,9 +248,9 @@ const assignability14: () => AsyncIterator<number> = async function * () {
>yield* [Promise.resolve(1)] : any
>[Promise.resolve(1)] : Promise<number>[]
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
};
@@ -283,9 +283,9 @@ async function * explicitReturnType2(): AsyncIterableIterator<number> {
yield Promise.resolve(1);
>yield Promise.resolve(1) : any
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
}
async function * explicitReturnType3(): AsyncIterableIterator<number> {
@@ -306,9 +306,9 @@ async function * explicitReturnType4(): AsyncIterableIterator<number> {
>yield* [Promise.resolve(1)] : any
>[Promise.resolve(1)] : Promise<number>[]
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
}
async function * explicitReturnType5(): AsyncIterableIterator<number> {
@@ -338,9 +338,9 @@ async function * explicitReturnType7(): AsyncIterable<number> {
yield Promise.resolve(1);
>yield Promise.resolve(1) : any
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
}
async function * explicitReturnType8(): AsyncIterable<number> {
@@ -361,9 +361,9 @@ async function * explicitReturnType9(): AsyncIterable<number> {
>yield* [Promise.resolve(1)] : any
>[Promise.resolve(1)] : Promise<number>[]
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
}
async function * explicitReturnType10(): AsyncIterable<number> {
@@ -393,9 +393,9 @@ async function * explicitReturnType12(): AsyncIterator<number> {
yield Promise.resolve(1);
>yield Promise.resolve(1) : any
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
}
async function * explicitReturnType13(): AsyncIterator<number> {
@@ -416,9 +416,9 @@ async function * explicitReturnType14(): AsyncIterator<number> {
>yield* [Promise.resolve(1)] : any
>[Promise.resolve(1)] : Promise<number>[]
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
}
async function * explicitReturnType15(): AsyncIterator<number> {
@@ -455,8 +455,8 @@ async function * awaitedType2() {
>x : number
>await Promise.resolve(1) : number
>Promise.resolve(1) : Promise<number>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise.resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>resolve : { <T>(value: T): Promise<promised T>; (): Promise<void>; }
>1 : 1
}
@@ -0,0 +1,96 @@
// @target: es2015
// @declaration: true
// simple
declare const p0: Promise<number>;
p0.then(x => x);
declare const p1: Promise<Promise<number>>;
p1.then(x => x);
declare const p2: Promise<number | Promise<number>>;
p2.then(x => x);
// generics
declare const f: boolean;
declare function makePromise<T>(x: T): Promise<T>;
makePromise(1).then(x => x);
makePromise("a").then(x => x);
makePromise({ a: 1 }).then(x => x);
makePromise(f ? 1 : "a").then(x => x);
function f0<U>(u: U) {
return makePromise(u).then(x => x);
}
f0(1).then(x => x);
f0("a").then(x => x);
f0(f ? 1 : "a").then(x => x);
f0(makePromise(1)).then(x => x);
function f1<U, V>(u: U, v: V) {
return makePromise(u).then(x => {
if (f) return x;
return makePromise(v).then(x => x);
});
}
f1(1, "a").then(x => x);
f1(makePromise(1), makePromise("a")).then(x => x);
function f2<U>(u: U) {
return makePromise(u).then(x => {
if (f) return x;
return Promise.reject("b");
});
}
f2(1).then(x => x);
f2(makePromise(1)).then(x => x);
function f3<U, V>(u: U, v: V) {
return makePromise(u).catch(x => v);
}
f3(1, "a").then(x => x);
f3(makePromise(1), makePromise("a")).then(x => x);
function f4<U, V>(u: U, v: V) {
return makePromise(u).catch(x => {
if (f) return v;
return Promise.reject("b");
});
}
f4(1, "a").then(x => x);
f4(makePromise(1), makePromise("a")).then(x => x);
async function f5<U>(u: Promise<U>) {
return await u;
}
f5(makePromise(1)).then(x => x);
f5(makePromise(makePromise(1))).then(x => x);
async function f6<U>(u: Promise<Promise<U>>) {
return await u;
}
// assignability
let v0: number;
let v1: promised number;
let v2: promised Promise<number>;
v0 = v1;
v0 = v2;
v1 = v0;
v1 = v2;
v2 = v0;
v2 = v1;
function f7<U>() {
let v0: promised U;
let v1: promised Promise<U>;
v0 = v1;
v1 = v0;
}
async function f8<U>() {
let pu: Promise<U>;
let v0: promised U;
let v1: promised Promise<U>;
v0 = await pu;
v1 = await pu;
}