Merge pull request #13487 from Microsoft/genericDefaults

Adds support for type parameter defaults
This commit is contained in:
Ron Buckton
2017-02-14 19:32:16 -08:00
committed by GitHub
58 changed files with 11596 additions and 2151 deletions
+247 -68
View File
@@ -865,6 +865,11 @@ namespace ts {
case SyntaxKind.ClassExpression:
case SyntaxKind.InterfaceDeclaration:
if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & SymbolFlags.Type)) {
if (!isTypeParameterSymbolDeclaredInContainer(result, location)) {
// ignore type parameters not declared in this container
result = undefined;
break;
}
if (lastLocation && getModifierFlags(lastLocation) & ModifierFlags.Static) {
// TypeScript 1.0 spec (April 2014): 3.4.1
// The scope of a type parameter extends over the entire declaration with which the type
@@ -1015,6 +1020,16 @@ namespace ts {
return result;
}
function isTypeParameterSymbolDeclaredInContainer(symbol: Symbol, container: Node) {
for (const decl of symbol.declarations) {
if (decl.kind === SyntaxKind.TypeParameter && decl.parent === container) {
return true;
}
}
return false;
}
function checkAndReportErrorForMissingPrefix(errorLocation: Node, name: string, nameArg: string | Identifier): boolean {
if ((errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(<Identifier>errorLocation)) || isInTypeQuery(errorLocation))) {
return false;
@@ -2336,7 +2351,7 @@ namespace ts {
else if (!(flags & TypeFormatFlags.InTypeAlias) && type.aliasSymbol &&
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) {
const typeArguments = type.aliasTypeArguments;
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, length(typeArguments), nextFlags);
}
else if (type.flags & TypeFlags.UnionOrIntersection) {
writeUnionOrIntersectionType(<UnionOrIntersectionType>type, nextFlags);
@@ -2671,6 +2686,13 @@ namespace ts {
writeSpace(writer);
buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack);
}
const defaultType = getDefaultFromTypeParameter(tp);
if (defaultType) {
writeSpace(writer);
writePunctuation(writer, SyntaxKind.EqualsToken);
writeSpace(writer);
buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack);
}
}
function buildParameterDisplay(p: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
@@ -3870,9 +3892,9 @@ namespace ts {
}
function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] {
const typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0;
const typeArgCount = length(typeArgumentNodes);
return filter(getSignaturesOfType(type, SignatureKind.Construct),
sig => (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount);
sig => typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= length(sig.typeParameters));
}
function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] {
@@ -4470,12 +4492,13 @@ namespace ts {
}
const baseTypeNode = getBaseTypeNodeOfClass(classType);
const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode);
const typeArgCount = typeArguments ? typeArguments.length : 0;
const typeArgCount = length(typeArguments);
const result: Signature[] = [];
for (const baseSig of baseSignatures) {
const typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0;
if (typeParamCount === typeArgCount) {
const sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig);
const minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters);
const typeParamCount = length(baseSig.typeParameters);
if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) {
const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig);
sig.typeParameters = classType.localTypeParameters;
sig.resolvedReturnType = classType;
result.push(sig);
@@ -4952,6 +4975,29 @@ namespace ts {
return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type));
}
/**
* Gets the default type for a type parameter.
*
* If the type parameter is the result of an instantiation, this gets the instantiated
* default type of its target. If the type parameter has no default type, `undefined`
* is returned.
*
* This function *does not* perform a circularity check.
*/
function getDefaultFromTypeParameter(typeParameter: TypeParameter): Type | undefined {
if (!typeParameter.default) {
if (typeParameter.target) {
const targetDefault = getDefaultFromTypeParameter(typeParameter.target);
typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType;
}
else {
const defaultDeclaration = typeParameter.symbol && forEach(typeParameter.symbol.declarations, decl => isTypeParameter(decl) && decl.default);
typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType;
}
}
return typeParameter.default === noConstraintType ? undefined : typeParameter.default;
}
/**
* For a type parameter, return the base constraint of the type parameter. For the string, number,
* boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
@@ -5241,6 +5287,55 @@ namespace ts {
}
}
/**
* Gets the minimum number of type arguments needed to satisfy all non-optional type
* parameters.
*/
function getMinTypeArgumentCount(typeParameters: TypeParameter[] | undefined): number {
let minTypeArgumentCount = 0;
if (typeParameters) {
for (let i = 0; i < typeParameters.length; i++) {
if (!getDefaultFromTypeParameter(typeParameters[i])) {
minTypeArgumentCount = i + 1;
}
}
}
return minTypeArgumentCount;
}
/**
* Fill in default types for unsupplied type arguments. If `typeArguments` is undefined
* when a default type is supplied, a new array will be created and returned.
*
* @param typeArguments The supplied type arguments.
* @param typeParameters The requested type parameters.
* @param minTypeArgumentCount The minimum number of required type arguments.
*/
function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number) {
const numTypeParameters = length(typeParameters);
if (numTypeParameters) {
const numTypeArguments = length(typeArguments);
if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) {
if (!typeArguments) {
typeArguments = [];
}
// Map an unsatisfied type parameter with a default type.
// If a type parameter does not have a default type, or if the default type
// is a forward reference, the empty object type is used.
for (let i = numTypeArguments; i < numTypeParameters; i++) {
typeArguments[i] = emptyObjectType;
}
for (let i = numTypeArguments; i < numTypeParameters; i++) {
const mapper = createTypeMapper(typeParameters, typeArguments);
const defaultType = getDefaultFromTypeParameter(typeParameters[i]);
typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType;
}
}
}
return typeArguments;
}
function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature {
const links = getNodeLinks(declaration);
if (!links.resolvedSignature) {
@@ -5440,6 +5535,7 @@ namespace ts {
}
function getSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature {
typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters));
const instantiations = signature.instantiations || (signature.instantiations = createMap<Signature>());
const id = getTypeListId(typeArguments);
let instantiation = instantiations.get(id);
@@ -5597,7 +5693,7 @@ namespace ts {
}
function getTypeReferenceArity(type: TypeReference): number {
return type.target.typeParameters ? type.target.typeParameters.length : 0;
return length(type.target.typeParameters);
}
// Get type from reference to class or interface
@@ -5605,14 +5701,23 @@ namespace ts {
const type = <InterfaceType>getDeclaredTypeOfSymbol(getMergedSymbol(symbol));
const typeParameters = type.localTypeParameters;
if (typeParameters) {
if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) {
error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType), typeParameters.length);
const numTypeArguments = length(node.typeArguments);
const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
error(node,
minTypeArgumentCount === typeParameters.length
? Diagnostics.Generic_type_0_requires_1_type_argument_s
: Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments,
typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType),
minTypeArgumentCount,
typeParameters.length);
return unknownType;
}
// In a type reference, the outer type parameters of the referenced class or interface are automatically
// supplied as type arguments and the type reference only specifies arguments for the local type parameters
// of the class or interface.
return createTypeReference(<GenericType>type, concatenate(type.outerTypeParameters, map(node.typeArguments, getTypeFromTypeNode)));
const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount));
return createTypeReference(<GenericType>type, typeArguments);
}
if (node.typeArguments) {
error(node, Diagnostics.Type_0_is_not_generic, typeToString(type));
@@ -5628,7 +5733,7 @@ namespace ts {
const id = getTypeListId(typeArguments);
let instantiation = links.instantiations.get(id);
if (!instantiation) {
links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments)));
links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters)))));
}
return instantiation;
}
@@ -5640,8 +5745,16 @@ namespace ts {
const type = getDeclaredTypeOfSymbol(symbol);
const typeParameters = getSymbolLinks(symbol).typeParameters;
if (typeParameters) {
if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) {
error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length);
const numTypeArguments = length(node.typeArguments);
const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
error(node,
minTypeArgumentCount === typeParameters.length
? Diagnostics.Generic_type_0_requires_1_type_argument_s
: Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments,
symbolToString(symbol),
minTypeArgumentCount,
typeParameters.length);
return unknownType;
}
const typeArguments = map(node.typeArguments, getTypeFromTypeNode);
@@ -5779,7 +5892,7 @@ namespace ts {
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name);
return arity ? emptyGenericType : emptyObjectType;
}
if (((<InterfaceType>type).typeParameters ? (<InterfaceType>type).typeParameters.length : 0) !== arity) {
if (length((<InterfaceType>type).typeParameters) !== arity) {
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity);
return arity ? emptyGenericType : emptyObjectType;
}
@@ -6695,6 +6808,16 @@ namespace ts {
return createTypeMapper(sources, undefined);
}
/**
* Maps forward-references to later types parameters to the empty object type.
* This is used during inference when instantiating type parameter defaults.
*/
function createBackreferenceMapper(typeParameters: TypeParameter[], index: number) {
const mapper: TypeMapper = t => indexOf(typeParameters, t) >= index ? emptyObjectType : t;
mapper.mappedTypes = typeParameters;
return mapper;
}
function getInferenceMapper(context: InferenceContext): TypeMapper {
if (!context.mapper) {
const mapper: TypeMapper = t => {
@@ -8428,7 +8551,7 @@ namespace ts {
// the constraints with a common set of type arguments to get relatable entities in places where
// type parameters occur in the constraints. The complexity of doing that doesn't seem worthwhile,
// particularly as we're comparing erased versions of the signatures below.
if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) {
if (length(source.typeParameters) !== length(target.typeParameters)) {
return Ternary.False;
}
// Spec 1.0 Section 3.8.3 & 3.8.4:
@@ -9251,11 +9374,24 @@ namespace ts {
inferenceSucceeded = !!unionOrSuperType;
}
else {
// Infer the empty object type when no inferences were made. It is important to remember that
// in this case, inference still succeeds, meaning there is no error for not having inference
// candidates. An inference error only occurs when there are *conflicting* candidates, i.e.
// Infer either the default or the empty object type when no inferences were
// made. It is important to remember that in this case, inference still
// succeeds, meaning there is no error for not having inference candidates. An
// inference error only occurs when there are *conflicting* candidates, i.e.
// candidates with no common supertype.
inferredType = emptyObjectType;
const defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]);
if (defaultType) {
// Instantiate the default type. Any forward reference to a type
// parameter should be instantiated to the empty object type.
inferredType = instantiateType(defaultType,
combineTypeMappers(
createBackreferenceMapper(context.signature.typeParameters, index),
getInferenceMapper(context)));
}
else {
inferredType = emptyObjectType;
}
inferenceSucceeded = true;
}
context.inferredTypes[index] = inferredType;
@@ -13024,8 +13160,10 @@ namespace ts {
// If the user supplied type arguments, but the number of type arguments does not match
// the declared number of type parameters, the call has an incorrect arity.
const numTypeParameters = length(signature.typeParameters);
const minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters);
const hasRightNumberOfTypeArgs = !typeArguments ||
(signature.typeParameters && typeArguments.length === signature.typeParameters.length);
(typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters);
if (!hasRightNumberOfTypeArgs) {
return false;
}
@@ -13147,7 +13285,7 @@ namespace ts {
const typeParameters = signature.typeParameters;
let typeArgumentsAreAssignable = true;
let mapper: TypeMapper;
for (let i = 0; i < typeParameters.length; i++) {
for (let i = 0; i < typeArgumentNodes.length; i++) {
if (typeArgumentsAreAssignable /* so far */) {
const constraint = getConstraintOfTypeParameter(typeParameters[i]);
if (constraint) {
@@ -13722,15 +13860,15 @@ namespace ts {
while (true) {
candidate = originalCandidate;
if (candidate.typeParameters) {
let typeArgumentTypes: Type[];
let typeArgumentTypes: Type[] | undefined;
if (typeArguments) {
typeArgumentTypes = map(typeArguments, getTypeFromTypeNode);
typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters));
typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false);
}
else {
inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext);
typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined;
typeArgumentTypes = inferenceContext.inferredTypes;
typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined;
}
if (!typeArgumentsAreValid) {
break;
@@ -15700,11 +15838,16 @@ namespace ts {
}
checkSourceElement(node.constraint);
checkSourceElement(node.default);
const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
if (!hasNonCircularBaseConstraint(typeParameter)) {
error(node.constraint, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter));
}
getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)));
const constraintType = getConstraintOfTypeParameter(typeParameter);
const defaultType = getDefaultFromTypeParameter(typeParameter);
if (constraintType && defaultType) {
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
}
if (produceDiagnostics) {
checkTypeNameIsReserved(node.name, Diagnostics.Type_parameter_name_cannot_be_0);
}
@@ -16297,6 +16440,7 @@ namespace ts {
}
function checkTypeArgumentConstraints(typeParameters: TypeParameter[], typeArgumentNodes: TypeNode[]): boolean {
const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
let typeArguments: Type[];
let mapper: TypeMapper;
let result = true;
@@ -16304,7 +16448,7 @@ namespace ts {
const constraint = getConstraintOfTypeParameter(typeParameters[i]);
if (constraint) {
if (!typeArguments) {
typeArguments = map(typeArgumentNodes, getTypeFromTypeNode);
typeArguments = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount);
mapper = createTypeMapper(typeParameters, typeArguments);
}
const typeArgument = typeArguments[i];
@@ -18545,14 +18689,23 @@ namespace ts {
}
}
/** Check each type parameter and check that type parameters have no duplicate type parameter declarations */
/**
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
*/
function checkTypeParameters(typeParameterDeclarations: TypeParameterDeclaration[]) {
if (typeParameterDeclarations) {
let seenDefault = false;
for (let i = 0; i < typeParameterDeclarations.length; i++) {
const node = typeParameterDeclarations[i];
checkTypeParameter(node);
if (produceDiagnostics) {
if (node.default) {
seenDefault = true;
}
else if (seenDefault) {
error(node, Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
}
for (let j = 0; j < i; j++) {
if (typeParameterDeclarations[j].symbol === node.symbol) {
error(node.name, Diagnostics.Duplicate_identifier_0, declarationNameToString(node.name));
@@ -18564,23 +18717,73 @@ namespace ts {
}
/** Check that type parameter lists are identical across multiple declarations */
function checkTypeParameterListsIdentical(node: ClassLikeDeclaration | InterfaceDeclaration, symbol: Symbol) {
function checkTypeParameterListsIdentical(symbol: Symbol) {
if (symbol.declarations.length === 1) {
return;
}
let firstDecl: ClassLikeDeclaration | InterfaceDeclaration;
for (const declaration of symbol.declarations) {
if (declaration.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.InterfaceDeclaration) {
if (!firstDecl) {
firstDecl = <ClassLikeDeclaration | InterfaceDeclaration>declaration;
}
else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) {
error(node.name, Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text);
const links = getSymbolLinks(symbol);
if (!links.typeParametersChecked) {
links.typeParametersChecked = true;
const declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol);
if (declarations.length <= 1) {
return;
}
const type = <InterfaceType>getDeclaredTypeOfSymbol(symbol);
if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
// Report an error on every conflicting declaration.
const name = symbolToString(symbol);
for (const declaration of declarations) {
error(declaration.name, Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
}
}
}
}
function areTypeParametersIdentical(declarations: (ClassDeclaration | InterfaceDeclaration)[], typeParameters: TypeParameter[]) {
const maxTypeArgumentCount = length(typeParameters);
const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
for (const declaration of declarations) {
// If this declaration has too few or too many type parameters, we report an error
const numTypeParameters = length(declaration.typeParameters);
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
return false;
}
for (let i = 0; i < numTypeParameters; i++) {
const source = declaration.typeParameters[i];
const target = typeParameters[i];
// If the type parameter node does not have the same as the resolved type
// parameter at this position, we report an error.
if (source.name.text !== target.symbol.name) {
return false;
}
// If the type parameter node does not have an identical constraint as the resolved
// type parameter at this position, we report an error.
const sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint);
const targetConstraint = getConstraintFromTypeParameter(target);
if ((sourceConstraint || targetConstraint) &&
(!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) {
return false;
}
// If the type parameter node has a default and it is not identical to the default
// for the type parameter at this position, we report an error.
const sourceDefault = source.default && getTypeFromTypeNode(source.default);
const targetDefault = getDefaultFromTypeParameter(target);
if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) {
return false;
}
}
}
return true;
}
function checkClassExpression(node: ClassExpression): Type {
checkClassLikeDeclaration(node);
checkNodeDeferred(node);
@@ -18618,7 +18821,7 @@ namespace ts {
const type = <InterfaceType>getDeclaredTypeOfSymbol(symbol);
const typeWithThis = getTypeWithThisArgument(type);
const staticType = <ObjectType>getTypeOfSymbol(symbol);
checkTypeParameterListsIdentical(node, symbol);
checkTypeParameterListsIdentical(symbol);
checkClassForDuplicateDeclarations(node);
// Only check for reserved static identifiers on non-ambient context.
@@ -18726,6 +18929,11 @@ namespace ts {
return forEach(symbol.declarations, d => isClassLike(d) ? d : undefined);
}
function getClassOrInterfaceDeclarationsOfSymbol(symbol: Symbol) {
return filter(symbol.declarations, (d: Declaration): d is ClassDeclaration | InterfaceDeclaration =>
d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.InterfaceDeclaration);
}
function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: BaseType): void {
// TypeScript 1.0 spec (April 2014): 8.2.3
@@ -18827,35 +19035,6 @@ namespace ts {
return kind === SyntaxKind.GetAccessor || kind === SyntaxKind.SetAccessor;
}
function areTypeParametersIdentical(list1: TypeParameterDeclaration[], list2: TypeParameterDeclaration[]) {
if (!list1 && !list2) {
return true;
}
if (!list1 || !list2 || list1.length !== list2.length) {
return false;
}
// TypeScript 1.0 spec (April 2014):
// When a generic interface has multiple declarations, all declarations must have identical type parameter
// lists, i.e. identical type parameter names with identical constraints in identical order.
for (let i = 0; i < list1.length; i++) {
const tp1 = list1[i];
const tp2 = list2[i];
if (tp1.name.text !== tp2.name.text) {
return false;
}
if (!tp1.constraint && !tp2.constraint) {
continue;
}
if (!tp1.constraint || !tp2.constraint) {
return false;
}
if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) {
return false;
}
}
return true;
}
function checkInheritedPropertiesAreIdentical(type: InterfaceType, typeNode: Node): boolean {
const baseTypes = getBaseTypes(type);
if (baseTypes.length < 2) {
@@ -18902,7 +19081,7 @@ namespace ts {
checkExportsOnMergedDeclarations(node);
const symbol = getSymbolOfNode(node);
checkTypeParameterListsIdentical(node, symbol);
checkTypeParameterListsIdentical(symbol);
// Only check this symbol once
const firstInterfaceDecl = <InterfaceDeclaration>getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration);
+17
View File
@@ -1010,6 +1010,23 @@ namespace ts {
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError);
}
}
if (node.default && !isPrivateMethodTypeParameter(node)) {
write(" = ");
if (node.parent.kind === SyntaxKind.FunctionType ||
node.parent.kind === SyntaxKind.ConstructorType ||
(node.parent.parent && node.parent.parent.kind === SyntaxKind.TypeLiteral)) {
Debug.assert(node.parent.kind === SyntaxKind.MethodDeclaration ||
node.parent.kind === SyntaxKind.MethodSignature ||
node.parent.kind === SyntaxKind.FunctionType ||
node.parent.kind === SyntaxKind.ConstructorType ||
node.parent.kind === SyntaxKind.CallSignature ||
node.parent.kind === SyntaxKind.ConstructSignature);
emitType(node.default);
}
else {
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError);
}
}
function getTypeParameterConstraintVisibilityError(): SymbolAccessibilityDiagnostic {
// Type parameter constraints are named by user so we should always be able to name it
+8
View File
@@ -2059,6 +2059,14 @@
"category": "Error",
"code": 2705
},
"Required type parameters may not follow optional type parameters.": {
"category": "Error",
"code": 2706
},
"Generic type '{0}' requires between {1} and {2} type arguments.": {
"category": "Error",
"code": 2707
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
+5
View File
@@ -66,6 +66,7 @@ namespace ts {
case SyntaxKind.TypeParameter:
return visitNode(cbNode, (<TypeParameterDeclaration>node).name) ||
visitNode(cbNode, (<TypeParameterDeclaration>node).constraint) ||
visitNode(cbNode, (<TypeParameterDeclaration>node).default) ||
visitNode(cbNode, (<TypeParameterDeclaration>node).expression);
case SyntaxKind.ShorthandPropertyAssignment:
return visitNodes(cbNodes, node.decorators) ||
@@ -2102,6 +2103,10 @@ namespace ts {
}
}
if (parseOptional(SyntaxKind.EqualsToken)) {
node.default = parseType();
}
return finishNode(node);
}
+5
View File
@@ -624,6 +624,7 @@
kind: SyntaxKind.TypeParameter;
name: Identifier;
constraint?: TypeNode;
default?: TypeNode;
// For error recovery purposes.
expression?: Expression;
@@ -2736,6 +2737,7 @@
isDiscriminantProperty?: boolean; // True if discriminant synthetic property
resolvedExports?: SymbolTable; // Resolved exports of module
exportsChecked?: boolean; // True if exports of external module have been checked
typeParametersChecked?: boolean; // True if type parameters of merged class and interface declarations have been checked.
isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration
bindingElement?: BindingElement; // Binding element associated with property symbol
exportsSomeValue?: boolean; // True if module exports some value (not just types)
@@ -3060,12 +3062,15 @@
// Type parameters (TypeFlags.TypeParameter)
export interface TypeParameter extends TypeVariable {
constraint: Type; // Constraint
default?: Type;
/* @internal */
target?: TypeParameter; // Instantiation target
/* @internal */
mapper?: TypeMapper; // Instantiation mapper
/* @internal */
isThisType?: boolean;
/* @internal */
resolvedDefaultType?: Type;
}
// Indexed access types (TypeFlags.IndexedAccess)
+14
View File
@@ -24,6 +24,20 @@ namespace ts {
return undefined;
}
export function findDeclaration<T extends Declaration>(symbol: Symbol, predicate: (node: Declaration) => node is T): T | undefined;
export function findDeclaration(symbol: Symbol, predicate: (node: Declaration) => boolean): Declaration | undefined;
export function findDeclaration(symbol: Symbol, predicate: (node: Declaration) => boolean): Declaration | undefined {
const declarations = symbol.declarations;
if (declarations) {
for (const declaration of declarations) {
if (predicate(declaration)) {
return declaration;
}
}
}
return undefined;
}
export interface StringSymbolWriter extends SymbolWriter {
string(): string;
}
-1
View File
@@ -1,4 +1,3 @@
interface PromiseConstructor {
/**
* A reference to the prototype.
+3 -66
View File
@@ -1310,39 +1310,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(
onfulfilled?: ((value: T) => T | PromiseLike<T>) | undefined | null,
onrejected?: ((reason: any) => T | PromiseLike<T>) | undefined | null): PromiseLike<T>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(
onfulfilled: ((value: T) => T | PromiseLike<T>) | undefined | null,
onrejected: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<T | TResult>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(
onfulfilled: (value: T) => TResult | PromiseLike<TResult>,
onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): PromiseLike<TResult>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult1, TResult2>(
onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>,
onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>;
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>;
}
/**
@@ -1355,45 +1323,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(onfulfilled?: ((value: T) => T | PromiseLike<T>) | undefined | null, onrejected?: ((reason: any) => T | PromiseLike<T>) | undefined | null): Promise<T>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled: ((value: T) => T | PromiseLike<T>) | undefined | null, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<TResult>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>;
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | 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(onrejected?: ((reason: any) => T | PromiseLike<T>) | undefined | null): Promise<T>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch<TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>;
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
}
interface ArrayLike<T> {
+1
View File
@@ -397,6 +397,7 @@ namespace ts {
parameters: Symbol[];
thisParameter: Symbol;
resolvedReturnType: Type;
minTypeArgumentCount: number;
minArgumentCount: number;
hasRestParameter: boolean;
hasLiteralTypes: boolean;
@@ -6,7 +6,7 @@ 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<any>'.
Types of property 'then' are incompatible.
Type '() => void' is not assignable to type '{ (onfulfilled?: (value: any) => any, onrejected?: (reason: any) => any): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => any, onrejected: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>; <TResult1, TResult2>(onfulfilled: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>; }'.
Type '() => void' is not assignable to type '<TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'.
Type 'void' is not assignable to type 'PromiseLike<any>'.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(17,16): error TS1059: Return expression in async function does not have a valid callable 'then' member.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(23,25): error TS1058: Operand for 'await' does not have a valid callable 'then' member.
@@ -37,7 +37,7 @@ 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<any>'.
!!! error TS1055: Types of property 'then' are incompatible.
!!! error TS1055: Type '() => void' is not assignable to type '{ (onfulfilled?: (value: any) => any, onrejected?: (reason: any) => any): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => any, onrejected: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>; <TResult1, TResult2>(onfulfilled: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>; }'.
!!! error TS1055: Type '() => void' is not assignable to type '<TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'.
!!! error TS1055: Type 'void' is not assignable to type 'PromiseLike<any>'.
async function fn7() { return; } // valid: Promise<void>
async function fn8() { return 1; } // valid: Promise<number>
@@ -1,7 +1,8 @@
tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts(27,11): error TS2428: All declarations of 'I' must have identical type parameters.
tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts(32,11): error TS2428: All declarations of 'I' must have identical type parameters.
==== tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts (1 errors) ====
==== tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts (2 errors) ====
// No errors expected for basic overloads of construct signatures with merged declarations
// clodules
@@ -29,6 +30,8 @@ tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSig
// merged interfaces
interface I {
~
!!! error TS2428: All declarations of 'I' must have identical type parameters.
new (x: number, y?: string): C;
new (x: number, y: string): C;
}
@@ -1,9 +1,10 @@
tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(1,42): error TS2300: Duplicate identifier 'A'.
tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(5,11): error TS2428: All declarations of 'InterfaceWithSomeTypars' must have identical type parameters.
tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(9,11): error TS2428: All declarations of 'InterfaceWithSomeTypars' must have identical type parameters.
tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(9,38): error TS2300: Duplicate identifier 'C'.
==== tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts (3 errors) ====
==== tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts (4 errors) ====
interface InterfaceWithMultipleTypars<A, A> { // should error
~
!!! error TS2300: Duplicate identifier 'A'.
@@ -11,6 +12,8 @@ tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(9,38): err
}
interface InterfaceWithSomeTypars<B> { // should not error
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2428: All declarations of 'InterfaceWithSomeTypars' must have identical type parameters.
bar(): void;
}
@@ -1,12 +1,17 @@
tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(3,11): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(7,11): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(12,15): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(16,15): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(34,22): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(40,22): error TS2428: All declarations of 'A' must have identical type parameters.
==== tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts (3 errors) ====
==== tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts (6 errors) ====
// generic and non-generic interfaces with the same name do not merge
interface A {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
foo: string;
}
@@ -18,6 +23,8 @@ tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterf
module M {
interface A<T> {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
bar: T;
}
@@ -42,6 +49,8 @@ tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterf
module M3 {
export interface A {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
foo: string;
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,110 @@
tests/cases/compiler/genericDefaultsErrors.ts(4,41): error TS2344: Type 'number' does not satisfy the constraint 'string'.
tests/cases/compiler/genericDefaultsErrors.ts(5,59): error TS2344: Type 'T' does not satisfy the constraint 'number'.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/genericDefaultsErrors.ts(6,44): error TS2344: Type 'T' does not satisfy the constraint 'number'.
tests/cases/compiler/genericDefaultsErrors.ts(7,39): error TS2344: Type 'number' does not satisfy the constraint 'T'.
tests/cases/compiler/genericDefaultsErrors.ts(11,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/genericDefaultsErrors.ts(14,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/genericDefaultsErrors.ts(18,13): error TS2345: Argument of type '"a"' is not assignable to parameter of type 'number'.
tests/cases/compiler/genericDefaultsErrors.ts(20,11): error TS2428: All declarations of 'i00' must have identical type parameters.
tests/cases/compiler/genericDefaultsErrors.ts(21,11): error TS2428: All declarations of 'i00' must have identical type parameters.
tests/cases/compiler/genericDefaultsErrors.ts(23,11): error TS2428: All declarations of 'i01' must have identical type parameters.
tests/cases/compiler/genericDefaultsErrors.ts(24,11): error TS2428: All declarations of 'i01' must have identical type parameters.
tests/cases/compiler/genericDefaultsErrors.ts(26,27): error TS2706: Required type parameters may not follow optional type parameters.
tests/cases/compiler/genericDefaultsErrors.ts(27,34): error TS2344: Type 'number' does not satisfy the constraint 'string'.
tests/cases/compiler/genericDefaultsErrors.ts(28,52): error TS2344: Type 'T' does not satisfy the constraint 'number'.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/genericDefaultsErrors.ts(29,37): error TS2344: Type 'T' does not satisfy the constraint 'number'.
tests/cases/compiler/genericDefaultsErrors.ts(30,32): error TS2344: Type 'number' does not satisfy the constraint 'T'.
tests/cases/compiler/genericDefaultsErrors.ts(33,15): error TS2707: Generic type 'i09<T, U, V>' requires between 2 and 3 type arguments.
tests/cases/compiler/genericDefaultsErrors.ts(34,15): error TS2707: Generic type 'i09<T, U, V>' requires between 2 and 3 type arguments.
tests/cases/compiler/genericDefaultsErrors.ts(37,15): error TS2707: Generic type 'i09<T, U, V>' requires between 2 and 3 type arguments.
tests/cases/compiler/genericDefaultsErrors.ts(39,20): error TS2304: Cannot find name 'T'.
tests/cases/compiler/genericDefaultsErrors.ts(39,20): error TS4033: Property 'x' of exported interface has or is using private name 'T'.
==== tests/cases/compiler/genericDefaultsErrors.ts (21 errors) ====
declare const x: any;
declare function f03<T extends string = number>(): void; // error
~~~~~~
!!! error TS2344: Type 'number' does not satisfy the constraint 'string'.
declare function f04<T extends string, U extends number = T>(): void; // error
~
!!! error TS2344: Type 'T' does not satisfy the constraint 'number'.
!!! error TS2344: Type 'string' is not assignable to type 'number'.
declare function f05<T, U extends number = T>(): void; // error
~
!!! error TS2344: Type 'T' does not satisfy the constraint 'number'.
declare function f06<T, U extends T = number>(): void; // error
~~~~~~
!!! error TS2344: Type 'number' does not satisfy the constraint 'T'.
declare function f11<T, U, V = number>(): void;
f11(); // ok
f11<1>(); // error
~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
f11<1, 2>(); // ok
f11<1, 2, 3>(); // ok
f11<1, 2, 3, 4>(); // error
~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
declare function f12<T, U = T>(a?: U): void;
f12<number>(); // ok
f12<number>("a"); // error
~~~
!!! error TS2345: Argument of type '"a"' is not assignable to parameter of type 'number'.
interface i00<T> { } // ok
~~~
!!! error TS2428: All declarations of 'i00' must have identical type parameters.
interface i00<U = number> { } // error
~~~
!!! error TS2428: All declarations of 'i00' must have identical type parameters.
interface i01<T = number> { } // ok
~~~
!!! error TS2428: All declarations of 'i01' must have identical type parameters.
interface i01<T = string> { } // error
~~~
!!! error TS2428: All declarations of 'i01' must have identical type parameters.
interface i04<T = number, U> { } // error
~
!!! error TS2706: Required type parameters may not follow optional type parameters.
interface i05<T extends string = number> { } // error
~~~~~~
!!! error TS2344: Type 'number' does not satisfy the constraint 'string'.
interface i06<T extends string, U extends number = T> { } // error
~
!!! error TS2344: Type 'T' does not satisfy the constraint 'number'.
!!! error TS2344: Type 'string' is not assignable to type 'number'.
interface i07<T, U extends number = T> { } // error
~
!!! error TS2344: Type 'T' does not satisfy the constraint 'number'.
interface i08<T, U extends T = number> { } // error
~~~~~~
!!! error TS2344: Type 'number' does not satisfy the constraint 'T'.
interface i09<T, U, V = number> { }
type i09t00 = i09; // error
~~~
!!! error TS2707: Generic type 'i09<T, U, V>' requires between 2 and 3 type arguments.
type i09t01 = i09<1>; // error
~~~~~~
!!! error TS2707: Generic type 'i09<T, U, V>' requires between 2 and 3 type arguments.
type i09t02 = i09<1, 2>; // ok
type i09t03 = i09<1, 2, 3>; // ok
type i09t04 = i09<1, 2, 3, 4>; // error
~~~~~~~~~~~~~~~
!!! error TS2707: Generic type 'i09<T, U, V>' requires between 2 and 3 type arguments.
interface i10 { x: T; } // error
~
!!! error TS2304: Cannot find name 'T'.
~
!!! error TS4033: Property 'x' of exported interface has or is using private name 'T'.
interface i10<T = number> {}
@@ -0,0 +1,50 @@
//// [genericDefaultsErrors.ts]
declare const x: any;
declare function f03<T extends string = number>(): void; // error
declare function f04<T extends string, U extends number = T>(): void; // error
declare function f05<T, U extends number = T>(): void; // error
declare function f06<T, U extends T = number>(): void; // error
declare function f11<T, U, V = number>(): void;
f11(); // ok
f11<1>(); // error
f11<1, 2>(); // ok
f11<1, 2, 3>(); // ok
f11<1, 2, 3, 4>(); // error
declare function f12<T, U = T>(a?: U): void;
f12<number>(); // ok
f12<number>("a"); // error
interface i00<T> { } // ok
interface i00<U = number> { } // error
interface i01<T = number> { } // ok
interface i01<T = string> { } // error
interface i04<T = number, U> { } // error
interface i05<T extends string = number> { } // error
interface i06<T extends string, U extends number = T> { } // error
interface i07<T, U extends number = T> { } // error
interface i08<T, U extends T = number> { } // error
interface i09<T, U, V = number> { }
type i09t00 = i09; // error
type i09t01 = i09<1>; // error
type i09t02 = i09<1, 2>; // ok
type i09t03 = i09<1, 2, 3>; // ok
type i09t04 = i09<1, 2, 3, 4>; // error
interface i10 { x: T; } // error
interface i10<T = number> {}
//// [genericDefaultsErrors.js]
f11(); // ok
f11(); // error
f11(); // ok
f11(); // ok
f11(); // error
f12(); // ok
f12("a"); // error
@@ -37,14 +37,14 @@ export class BrokenClass {
>reject : Symbol(reject, Decl(file1.ts, 13, 34))
this.doStuff(order.id)
>this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>this.doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3))
>this : Symbol(BrokenClass, Decl(file1.ts, 1, 39))
>doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3))
>order : Symbol(order, Decl(file1.ts, 12, 25))
.then((items) => {
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>items : Symbol(items, Decl(file1.ts, 15, 17))
order.items = items;
@@ -60,7 +60,7 @@ export class BrokenClass {
};
return Promise.all(result.map(populateItems))
>Promise.all(result.map(populateItems)) .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Promise.all(result.map(populateItems)) .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
@@ -70,7 +70,7 @@ export class BrokenClass {
>populateItems : Symbol(populateItems, Decl(file1.ts, 12, 7))
.then((orders: Array<MyModule.MyModel>) => {
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>orders : Symbol(orders, Decl(file1.ts, 23, 13))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6))
@@ -46,7 +46,7 @@ export class BrokenClass {
this.doStuff(order.id)
>this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }) : Promise<void>
>this.doStuff(order.id) .then : { (onfulfilled?: (value: void) => void | PromiseLike<void>, onrejected?: (reason: any) => void | PromiseLike<void>): Promise<void>; <TResult>(onfulfilled: (value: void) => void | PromiseLike<void>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<void | TResult>; <TResult>(onfulfilled: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | 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 : { (onfulfilled?: (value: void) => void | PromiseLike<void>, onrejected?: (reason: any) => void | PromiseLike<void>): Promise<void>; <TResult>(onfulfilled: (value: void) => void | PromiseLike<void>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<void | TResult>; <TResult>(onfulfilled: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(onfulfilled: (value: void) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; }
>then : <TResult1 = void, TResult2 = never>(onfulfilled?: (value: void) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>(items) => { order.items = items; resolve(order); } : (items: void) => void
>items : void
@@ -78,7 +78,7 @@ 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 : { (onfulfilled?: (value: {}[]) => {}[] | PromiseLike<{}[]>, onrejected?: (reason: any) => {}[] | PromiseLike<{}[]>): Promise<{}[]>; <TResult>(onfulfilled: (value: {}[]) => {}[] | PromiseLike<{}[]>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<{}[] | TResult>; <TResult>(onfulfilled: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>Promise.all(result.map(populateItems)) : Promise<{}[]>
>Promise.all : { <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>; <T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: (T | PromiseLike<T>)[]): Promise<T[]>; <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; }
>Promise : PromiseConstructor
@@ -90,7 +90,7 @@ export class BrokenClass {
>populateItems : (order: any) => Promise<{}>
.then((orders: Array<MyModule.MyModel>) => {
>then : { (onfulfilled?: (value: {}[]) => {}[] | PromiseLike<{}[]>, onrejected?: (reason: any) => {}[] | PromiseLike<{}[]>): Promise<{}[]>; <TResult>(onfulfilled: (value: {}[]) => {}[] | PromiseLike<{}[]>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<{}[] | TResult>; <TResult>(onfulfilled: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(onfulfilled: (value: {}[]) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; }
>then : <TResult1 = {}[], TResult2 = never>(onfulfilled?: (value: {}[]) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>(orders: Array<MyModule.MyModel>) => { resolve(orders); } : (orders: MyModule.MyModel[]) => void
>orders : MyModule.MyModel[]
>Array : T[]
@@ -1,18 +1,23 @@
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(1,11): error TS2428: All declarations of 'I1' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(3,11): error TS2428: All declarations of 'I1' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(5,11): error TS2428: All declarations of 'I1' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(7,11): error TS2428: All declarations of 'I1' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(9,11): error TS2428: All declarations of 'I1' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(11,11): error TS2428: All declarations of 'I1' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(14,11): error TS2428: All declarations of 'I2' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(16,11): error TS2428: All declarations of 'I2' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(18,11): error TS2428: All declarations of 'I2' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(20,11): error TS2428: All declarations of 'I2' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(22,11): error TS2428: All declarations of 'I2' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(24,11): error TS2428: All declarations of 'I2' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(27,11): error TS2428: All declarations of 'I3' must have identical type parameters.
tests/cases/compiler/interfaceWithMultipleDeclarations.ts(29,11): error TS2428: All declarations of 'I3' must have identical type parameters.
==== tests/cases/compiler/interfaceWithMultipleDeclarations.ts (11 errors) ====
==== tests/cases/compiler/interfaceWithMultipleDeclarations.ts (14 errors) ====
interface I1<V> {
~~
!!! error TS2428: All declarations of 'I1' must have identical type parameters.
}
interface I1<S> { // Name mismatch
~~
@@ -36,6 +41,8 @@ tests/cases/compiler/interfaceWithMultipleDeclarations.ts(29,11): error TS2428:
}
interface I2<T extends string> {
~~
!!! error TS2428: All declarations of 'I2' must have identical type parameters.
}
interface I2<T extends () => string> { // constraint mismatch
~~
@@ -59,6 +66,8 @@ tests/cases/compiler/interfaceWithMultipleDeclarations.ts(29,11): error TS2428:
}
interface I3 {
~~
!!! error TS2428: All declarations of 'I3' must have identical type parameters.
}
interface I3<T> { // length mismatch
~~
@@ -121,9 +121,9 @@ declare var console: any;
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 52, 11))
out().then(() => {
>out().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>out().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 45, 37))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
console.log("Yea!");
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 52, 11))
@@ -148,10 +148,10 @@ declare var console: any;
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; <TResult>(onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<{} | TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; }
>out().then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>out() : Promise<{}>
>out : () => Promise<{}>
>then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; <TResult>(onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<{} | TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; }
>then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>() => { console.log("Yea!");} : () => void
console.log("Yea!");
@@ -121,9 +121,9 @@ declare var console: any;
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 52, 11))
out().then(() => {
>out().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>out().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 45, 37))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
console.log("Yea!");
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 52, 11))
@@ -148,10 +148,10 @@ declare var console: any;
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; <TResult>(onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<{} | TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; }
>out().then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>out() : Promise<{}>
>out : () => Promise<{}>
>then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; <TResult>(onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<{} | TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; }
>then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>() => { console.log("Yea!");} : () => void
console.log("Yea!");
@@ -121,9 +121,9 @@ declare var console: any;
>console : Symbol(console, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 52, 11))
out().then(() => {
>out().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>out().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>out : Symbol(out, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 45, 37))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
console.log("Yea!");
>console : Symbol(console, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 52, 11))
@@ -148,10 +148,10 @@ declare var console: any;
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; <TResult>(onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<{} | TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; }
>out().then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>out() : Promise<{}>
>out : () => Promise<{}>
>then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; <TResult>(onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<{} | TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; }
>then : <TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>() => { console.log("Yea!");} : () => void
console.log("Yea!");
@@ -1,4 +1,5 @@
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(5,5): error TS2375: Duplicate number index signature.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(8,11): error TS2428: All declarations of 'I' must have identical type parameters.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(10,5): error TS2375: Duplicate number index signature.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(15,5): error TS2375: Duplicate number index signature.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(20,5): error TS2375: Duplicate number index signature.
@@ -8,7 +9,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericI
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(30,5): error TS2375: Duplicate number index signature.
==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts (8 errors) ====
==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts (9 errors) ====
// Multiple indexers of the same type are an error
class C {
@@ -19,6 +20,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericI
}
interface I {
~
!!! error TS2428: All declarations of 'I' must have identical type parameters.
[x: number]: string;
[x: number]: string;
~~~~~~~~~~~~~~~~~~~~
@@ -1,9 +1,12 @@
tests/cases/compiler/nonIdenticalTypeConstraints.ts(7,7): error TS2428: All declarations of 'Foo' must have identical type parameters.
tests/cases/compiler/nonIdenticalTypeConstraints.ts(10,11): error TS2428: All declarations of 'Foo' must have identical type parameters.
tests/cases/compiler/nonIdenticalTypeConstraints.ts(13,11): error TS2428: All declarations of 'Qux' must have identical type parameters.
tests/cases/compiler/nonIdenticalTypeConstraints.ts(16,7): error TS2428: All declarations of 'Qux' must have identical type parameters.
tests/cases/compiler/nonIdenticalTypeConstraints.ts(33,7): error TS2428: All declarations of 'Quux' must have identical type parameters.
tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All declarations of 'Quux' must have identical type parameters.
==== tests/cases/compiler/nonIdenticalTypeConstraints.ts (3 errors) ====
==== tests/cases/compiler/nonIdenticalTypeConstraints.ts (6 errors) ====
class Different {
a: number;
b: string;
@@ -11,6 +14,8 @@ tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All de
}
class Foo<T extends Function> {
~~~
!!! error TS2428: All declarations of 'Foo' must have identical type parameters.
n: T;
}
interface Foo<T extends Different> {
@@ -19,6 +24,8 @@ tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All de
y: T;
}
interface Qux<T extends Different> {
~~~
!!! error TS2428: All declarations of 'Qux' must have identical type parameters.
y: T;
}
class Qux<T extends Function> {
@@ -41,6 +48,8 @@ tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All de
}
class Quux<T> {
~~~~
!!! error TS2428: All declarations of 'Quux' must have identical type parameters.
n: T;
}
interface Quux<U> {
@@ -51,9 +51,9 @@ tests/cases/compiler/promisePermutations.ts(144,12): error TS2453: The type argu
tests/cases/compiler/promisePermutations.ts(152,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'Promise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
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 '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
Type '(value: number) => number | PromiseLike<number>' is not assignable to type '(value: string) => IPromise<any>'.
Type '(value: number) => any' is not assignable to type '(value: string) => IPromise<any>'.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations.ts(156,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
@@ -68,9 +68,9 @@ 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 '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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>; }'.
Types of parameters 'onfulfilled' and 'success' are incompatible.
Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => number | PromiseLike<number>'.
Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => any'.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
@@ -310,9 +310,9 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
!!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'Promise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
!!! error TS2453: Types of property 'then' are incompatible.
!!! error TS2453: 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 '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 TS2453: 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 TS2453: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2453: Type '(value: number) => number | PromiseLike<number>' is not assignable to type '(value: string) => IPromise<any>'.
!!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => IPromise<any>'.
!!! error TS2453: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
@@ -339,9 +339,9 @@ 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 '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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: Types of parameters 'onfulfilled' and 'success' are incompatible.
!!! error TS2345: Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => number | PromiseLike<number>'.
!!! error TS2345: Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => any'.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
@@ -51,9 +51,9 @@ tests/cases/compiler/promisePermutations2.ts(143,12): error TS2453: The type arg
tests/cases/compiler/promisePermutations2.ts(151,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'Promise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
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 '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
Type '(value: number) => number | PromiseLike<number>' is not assignable to type '(value: string) => IPromise<any>'.
Type '(value: number) => any' is not assignable to type '(value: string) => IPromise<any>'.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations2.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
@@ -68,9 +68,9 @@ 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 '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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>; }'.
Types of parameters 'onfulfilled' and 'success' are incompatible.
Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => number | PromiseLike<number>'.
Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => any'.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
@@ -309,9 +309,9 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
!!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'Promise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
!!! error TS2453: Types of property 'then' are incompatible.
!!! error TS2453: 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 '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 TS2453: 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 TS2453: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2453: Type '(value: number) => number | PromiseLike<number>' is not assignable to type '(value: string) => IPromise<any>'.
!!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => IPromise<any>'.
!!! error TS2453: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
@@ -338,9 +338,9 @@ 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 '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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: Types of parameters 'onfulfilled' and 'success' are incompatible.
!!! error TS2345: Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => number | PromiseLike<number>'.
!!! error TS2345: Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => any'.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
@@ -54,9 +54,9 @@ tests/cases/compiler/promisePermutations3.ts(143,12): error TS2453: The type arg
tests/cases/compiler/promisePermutations3.ts(151,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'Promise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
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 '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
Type '(value: number) => number | PromiseLike<number>' is not assignable to type '(value: string) => any'.
Type '(value: number) => any' is not assignable to type '(value: string) => any'.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations3.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
@@ -71,15 +71,15 @@ 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 '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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>'.
Types of parameters 'onfulfilled' and 'success' are incompatible.
Type '(value: string) => any' is not assignable to type '(value: number) => number | PromiseLike<number>'.
Type '(value: string) => any' is not assignable to type '(value: number) => any'.
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 '{ (onfulfilled?: (value: any) => any, onrejected?: (reason: any) => any): Promise<any>; <TResult>(onfulfilled: (value: any) => any, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<any>; <TResult>(onfulfilled: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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 'IPromise<any>' is not assignable to type 'Promise<any>'.
@@ -321,9 +321,9 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
!!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'Promise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
!!! error TS2453: Types of property 'then' are incompatible.
!!! error TS2453: Type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 TS2453: 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 TS2453: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2453: Type '(value: number) => number | PromiseLike<number>' is not assignable to type '(value: string) => any'.
!!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => any'.
!!! error TS2453: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
@@ -350,9 +350,9 @@ 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 '{ (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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: Types of parameters 'onfulfilled' and 'success' are incompatible.
!!! error TS2345: Type '(value: string) => any' is not assignable to type '(value: number) => number | PromiseLike<number>'.
!!! error TS2345: Type '(value: string) => any' is not assignable to type '(value: number) => any'.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
@@ -365,6 +365,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 '{ (onfulfilled?: (value: any) => any, onrejected?: (reason: any) => any): Promise<any>; <TResult>(onfulfilled: (value: any) => any, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<any>; <TResult>(onfulfilled: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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 'IPromise<any>' is not assignable to type 'Promise<any>'.
var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok
@@ -5,7 +5,7 @@ interface Promise<T> {
>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 18))
then<A>(success?: (value: T) => Promise<A>): Promise<A>;
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60))
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60))
>A : Symbol(A, Decl(promiseTest.ts, 2, 9))
>success : Symbol(success, Decl(promiseTest.ts, 2, 12))
>value : Symbol(value, Decl(promiseTest.ts, 2, 23))
@@ -16,7 +16,7 @@ interface Promise<T> {
>A : Symbol(A, Decl(promiseTest.ts, 2, 9))
then<B>(success?: (value: T) => B): Promise<B>;
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60))
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60))
>B : Symbol(B, Decl(promiseTest.ts, 3, 9))
>success : Symbol(success, Decl(promiseTest.ts, 3, 12))
>value : Symbol(value, Decl(promiseTest.ts, 3, 23))
@@ -36,9 +36,9 @@ var p: Promise<number> = null;
var p2 = p.then(function (x) {
>p2 : Symbol(p2, Decl(promiseTest.ts, 8, 3))
>p.then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60))
>p.then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60))
>p : Symbol(p, Decl(promiseTest.ts, 7, 3))
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60))
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60))
>x : Symbol(x, Decl(promiseTest.ts, 8, 26))
return p;
+4 -4
View File
@@ -5,7 +5,7 @@ interface Promise<T> {
>T : T
then<A>(success?: (value: T) => Promise<A>): Promise<A>;
>then : { (onfulfilled?: (value: T) => T | PromiseLike<T>, onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>; <TResult>(onfulfilled: (value: T) => T | PromiseLike<T>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>; <TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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: 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>; }
>A : A
>success : (value: T) => Promise<A>
>value : T
@@ -16,7 +16,7 @@ interface Promise<T> {
>A : A
then<B>(success?: (value: T) => B): Promise<B>;
>then : { (onfulfilled?: (value: T) => T | PromiseLike<T>, onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>; <TResult>(onfulfilled: (value: T) => T | PromiseLike<T>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>; <TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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: 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>; }
>B : B
>success : (value: T) => B
>value : T
@@ -38,9 +38,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 : { (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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 : Promise<number>
>then : { (onfulfilled?: (value: number) => number | PromiseLike<number>, onrejected?: (reason: any) => number | PromiseLike<number>): Promise<number>; <TResult>(onfulfilled: (value: number) => number | PromiseLike<number>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<number | TResult>; <TResult>(onfulfilled: (value: number) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | 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>; }
>function (x) { return p;} : (x: number) => Promise<number>
>x : number
+264 -139
View File
@@ -1,16 +1,6 @@
//// [promiseType.ts]
declare var p: Promise<boolean>;
const a = p.then();
const b = p.then(b => 1);
const c = p.then(b => 1, e => 'error');
const d = p.then(b => 1, e => { });
const e = p.then(b => 1, e => { throw Error(); });
const f = p.then(b => 1, e => Promise.reject(Error()));
const g = p.catch(e => 'error');
const h = p.catch(e => { });
const i = p.catch(e => { throw Error(); });
const j = p.catch(e => Promise.reject(Error()));
declare var x: any;
async function A() {
const a = await p;
@@ -22,17 +12,15 @@ async function B() {
return 1;
}
// NOTE: This reports a "No best comment type exists among return expressions." error, and is
// ignored to get the types result for the test.
// async function C() {
// try {
// const a = await p;
// return 1;
// }
// catch (e) {
// return 'error';
// }
// }
async function C() {
try {
const a = await p;
return 1;
}
catch (e) {
return 'error';
}
}
async function D() {
try {
@@ -96,64 +84,140 @@ async function I() {
// addresses github issue #4903:
const p00 = p.catch();
const p01 = p.catch(undefined);
const p07 = p.catch(null);
const p02 = p.catch(() => 1);
const p03 = p.catch(() => {});
const p04 = p.catch(() => {throw 1});
const p05 = p.catch(() => Promise.reject(1));
const p06 = p.catch(() => Promise.resolve(1));
const p01 = p.then();
const p10 = p.then();
const p10 = p.catch(undefined);
const p11 = p.catch(null);
const p12 = p.catch(() => 1);
const p13 = p.catch(() => x);
const p14 = p.catch(() => undefined);
const p15 = p.catch(() => null);
const p16 = p.catch(() => {});
const p17 = p.catch(() => {throw 1});
const p18 = p.catch(() => Promise.reject(1));
const p19 = p.catch(() => Promise.resolve(1));
const p20 = p.then(undefined);
const p21 = p.then(() => 1);
const p22 = p.then(() => {});
const p23 = p.then(() => {throw 1});
const p24 = p.then(() => Promise.resolve(1));
const p25 = p.then(() => Promise.reject(1));
const p21 = p.then(null);
const p22 = p.then(() => 1);
const p23 = p.then(() => x);
const p24 = p.then(() => undefined);
const p25 = p.then(() => null);
const p26 = p.then(() => {});
const p27 = p.then(() => {throw 1});
const p28 = p.then(() => Promise.resolve(1));
const p29 = p.then(() => Promise.reject(1));
const p30 = p.then(undefined, undefined);
const p31 = p.then(undefined, () => 1);
const p32 = p.then(undefined, () => {});
const p33 = p.then(undefined, () => {throw 1});
const p34 = p.then(undefined, () => Promise.resolve(1));
const p35 = p.then(undefined, () => Promise.reject(1));
const p31 = p.then(undefined, null);
const p32 = p.then(undefined, () => 1);
const p33 = p.then(undefined, () => x);
const p34 = p.then(undefined, () => undefined);
const p35 = p.then(undefined, () => null);
const p36 = p.then(undefined, () => {});
const p37 = p.then(undefined, () => {throw 1});
const p38 = p.then(undefined, () => Promise.resolve(1));
const p39 = p.then(undefined, () => Promise.reject(1));
const p40 = p.then(() => "1", undefined);
const p41 = p.then(() => "1", () => 1);
const p42 = p.then(() => "1", () => {});
const p43 = p.then(() => "1", () => {throw 1});
const p44 = p.then(() => "1", () => Promise.resolve(1));
const p45 = p.then(() => "1", () => Promise.reject(1));
const p40 = p.then(null, undefined);
const p41 = p.then(null, null);
const p42 = p.then(null, () => 1);
const p43 = p.then(null, () => x);
const p44 = p.then(null, () => undefined);
const p45 = p.then(null, () => null);
const p46 = p.then(null, () => {});
const p47 = p.then(null, () => {throw 1});
const p48 = p.then(null, () => Promise.resolve(1));
const p49 = p.then(null, () => Promise.reject(1));
const p50 = p.then(() => {}, undefined);
const p51 = p.then(() => {}, () => 1);
const p52 = p.then(() => {}, () => {});
const p53 = p.then(() => {}, () => {throw 1});
const p54 = p.then(() => {}, () => Promise.resolve(1));
const p55 = p.then(() => {}, () => Promise.reject(1));
const p50 = p.then(() => "1", undefined);
const p51 = p.then(() => "1", null);
const p52 = p.then(() => "1", () => 1);
const p53 = p.then(() => "1", () => x);
const p54 = p.then(() => "1", () => undefined);
const p55 = p.then(() => "1", () => null);
const p56 = p.then(() => "1", () => {});
const p57 = p.then(() => "1", () => {throw 1});
const p58 = p.then(() => "1", () => Promise.resolve(1));
const p59 = p.then(() => "1", () => Promise.reject(1));
const p60 = p.then(() => {throw 1}, undefined);
const p61 = p.then(() => {throw 1}, () => 1);
const p62 = p.then(() => {throw 1}, () => {});
const p63 = p.then(() => {throw 1}, () => {throw 1});
const p64 = p.then(() => {throw 1}, () => Promise.resolve(1));
const p65 = p.then(() => {throw 1}, () => Promise.reject(1));
const p60 = p.then(() => x, undefined);
const p61 = p.then(() => x, null);
const p62 = p.then(() => x, () => 1);
const p63 = p.then(() => x, () => x);
const p64 = p.then(() => x, () => undefined);
const p65 = p.then(() => x, () => null);
const p66 = p.then(() => x, () => {});
const p67 = p.then(() => x, () => {throw 1});
const p68 = p.then(() => x, () => Promise.resolve(1));
const p69 = p.then(() => x, () => Promise.reject(1));
const p70 = p.then(() => Promise.resolve("1"), undefined);
const p71 = p.then(() => Promise.resolve("1"), () => 1);
const p72 = p.then(() => Promise.resolve("1"), () => {});
const p73 = p.then(() => Promise.resolve("1"), () => {throw 1});
const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const p70 = p.then(() => undefined, undefined);
const p71 = p.then(() => undefined, null);
const p72 = p.then(() => undefined, () => 1);
const p73 = p.then(() => undefined, () => x);
const p74 = p.then(() => undefined, () => undefined);
const p75 = p.then(() => undefined, () => null);
const p76 = p.then(() => undefined, () => {});
const p77 = p.then(() => undefined, () => {throw 1});
const p78 = p.then(() => undefined, () => Promise.resolve(1));
const p79 = p.then(() => undefined, () => Promise.reject(1));
const p80 = p.then(() => Promise.reject(1), undefined);
const p81 = p.then(() => Promise.reject(1), () => 1);
const p82 = p.then(() => Promise.reject(1), () => {});
const p83 = p.then(() => Promise.reject(1), () => {throw 1});
const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1));
const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1));
const p80 = p.then(() => null, undefined);
const p81 = p.then(() => null, null);
const p82 = p.then(() => null, () => 1);
const p83 = p.then(() => null, () => x);
const p84 = p.then(() => null, () => undefined);
const p85 = p.then(() => null, () => null);
const p86 = p.then(() => null, () => {});
const p87 = p.then(() => null, () => {throw 1});
const p88 = p.then(() => null, () => Promise.resolve(1));
const p89 = p.then(() => null, () => Promise.reject(1));
const p90 = p.then(() => {}, undefined);
const p91 = p.then(() => {}, null);
const p92 = p.then(() => {}, () => 1);
const p93 = p.then(() => {}, () => x);
const p94 = p.then(() => {}, () => undefined);
const p95 = p.then(() => {}, () => null);
const p96 = p.then(() => {}, () => {});
const p97 = p.then(() => {}, () => {throw 1});
const p98 = p.then(() => {}, () => Promise.resolve(1));
const p99 = p.then(() => {}, () => Promise.reject(1));
const pa0 = p.then(() => {throw 1}, undefined);
const pa1 = p.then(() => {throw 1}, null);
const pa2 = p.then(() => {throw 1}, () => 1);
const pa3 = p.then(() => {throw 1}, () => x);
const pa4 = p.then(() => {throw 1}, () => undefined);
const pa5 = p.then(() => {throw 1}, () => null);
const pa6 = p.then(() => {throw 1}, () => {});
const pa7 = p.then(() => {throw 1}, () => {throw 1});
const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1));
const pa9 = p.then(() => {throw 1}, () => Promise.reject(1));
const pb0 = p.then(() => Promise.resolve("1"), undefined);
const pb1 = p.then(() => Promise.resolve("1"), null);
const pb2 = p.then(() => Promise.resolve("1"), () => 1);
const pb3 = p.then(() => Promise.resolve("1"), () => x);
const pb4 = p.then(() => Promise.resolve("1"), () => undefined);
const pb5 = p.then(() => Promise.resolve("1"), () => null);
const pb6 = p.then(() => Promise.resolve("1"), () => {});
const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1});
const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const pc0 = p.then(() => Promise.reject("1"), undefined);
const pc1 = p.then(() => Promise.reject("1"), null);
const pc2 = p.then(() => Promise.reject("1"), () => 1);
const pc3 = p.then(() => Promise.reject("1"), () => x);
const pc4 = p.then(() => Promise.reject("1"), () => undefined);
const pc5 = p.then(() => Promise.reject("1"), () => null);
const pc6 = p.then(() => Promise.reject("1"), () => {});
const pc7 = p.then(() => Promise.reject("1"), () => {throw 1});
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
//// [promiseType.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -164,16 +228,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
const a = p.then();
const b = p.then(b => 1);
const c = p.then(b => 1, e => 'error');
const d = p.then(b => 1, e => { });
const e = p.then(b => 1, e => { throw Error(); });
const f = p.then(b => 1, e => Promise.reject(Error()));
const g = p.catch(e => 'error');
const h = p.catch(e => { });
const i = p.catch(e => { throw Error(); });
const j = p.catch(e => Promise.reject(Error()));
function A() {
return __awaiter(this, void 0, void 0, function* () {
const a = yield p;
@@ -186,17 +240,17 @@ function B() {
return 1;
});
}
// NOTE: This reports a "No best comment type exists among return expressions." error, and is
// ignored to get the types result for the test.
// async function C() {
// try {
// const a = await p;
// return 1;
// }
// catch (e) {
// return 'error';
// }
// }
function C() {
return __awaiter(this, void 0, void 0, function* () {
try {
const a = yield p;
return 1;
}
catch (e) {
return 'error';
}
});
}
function D() {
return __awaiter(this, void 0, void 0, function* () {
try {
@@ -264,53 +318,124 @@ function I() {
}
// addresses github issue #4903:
const p00 = p.catch();
const p01 = p.catch(undefined);
const p07 = p.catch(null);
const p02 = p.catch(() => 1);
const p03 = p.catch(() => { });
const p04 = p.catch(() => { throw 1; });
const p05 = p.catch(() => Promise.reject(1));
const p06 = p.catch(() => Promise.resolve(1));
const p10 = p.then();
const p01 = p.then();
const p10 = p.catch(undefined);
const p11 = p.catch(null);
const p12 = p.catch(() => 1);
const p13 = p.catch(() => x);
const p14 = p.catch(() => undefined);
const p15 = p.catch(() => null);
const p16 = p.catch(() => { });
const p17 = p.catch(() => { throw 1; });
const p18 = p.catch(() => Promise.reject(1));
const p19 = p.catch(() => Promise.resolve(1));
const p20 = p.then(undefined);
const p21 = p.then(() => 1);
const p22 = p.then(() => { });
const p23 = p.then(() => { throw 1; });
const p24 = p.then(() => Promise.resolve(1));
const p25 = p.then(() => Promise.reject(1));
const p21 = p.then(null);
const p22 = p.then(() => 1);
const p23 = p.then(() => x);
const p24 = p.then(() => undefined);
const p25 = p.then(() => null);
const p26 = p.then(() => { });
const p27 = p.then(() => { throw 1; });
const p28 = p.then(() => Promise.resolve(1));
const p29 = p.then(() => Promise.reject(1));
const p30 = p.then(undefined, undefined);
const p31 = p.then(undefined, () => 1);
const p32 = p.then(undefined, () => { });
const p33 = p.then(undefined, () => { throw 1; });
const p34 = p.then(undefined, () => Promise.resolve(1));
const p35 = p.then(undefined, () => Promise.reject(1));
const p40 = p.then(() => "1", undefined);
const p41 = p.then(() => "1", () => 1);
const p42 = p.then(() => "1", () => { });
const p43 = p.then(() => "1", () => { throw 1; });
const p44 = p.then(() => "1", () => Promise.resolve(1));
const p45 = p.then(() => "1", () => Promise.reject(1));
const p50 = p.then(() => { }, undefined);
const p51 = p.then(() => { }, () => 1);
const p52 = p.then(() => { }, () => { });
const p53 = p.then(() => { }, () => { throw 1; });
const p54 = p.then(() => { }, () => Promise.resolve(1));
const p55 = p.then(() => { }, () => Promise.reject(1));
const p60 = p.then(() => { throw 1; }, undefined);
const p61 = p.then(() => { throw 1; }, () => 1);
const p62 = p.then(() => { throw 1; }, () => { });
const p63 = p.then(() => { throw 1; }, () => { throw 1; });
const p64 = p.then(() => { throw 1; }, () => Promise.resolve(1));
const p65 = p.then(() => { throw 1; }, () => Promise.reject(1));
const p70 = p.then(() => Promise.resolve("1"), undefined);
const p71 = p.then(() => Promise.resolve("1"), () => 1);
const p72 = p.then(() => Promise.resolve("1"), () => { });
const p73 = p.then(() => Promise.resolve("1"), () => { throw 1; });
const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const p80 = p.then(() => Promise.reject(1), undefined);
const p81 = p.then(() => Promise.reject(1), () => 1);
const p82 = p.then(() => Promise.reject(1), () => { });
const p83 = p.then(() => Promise.reject(1), () => { throw 1; });
const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1));
const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1));
const p31 = p.then(undefined, null);
const p32 = p.then(undefined, () => 1);
const p33 = p.then(undefined, () => x);
const p34 = p.then(undefined, () => undefined);
const p35 = p.then(undefined, () => null);
const p36 = p.then(undefined, () => { });
const p37 = p.then(undefined, () => { throw 1; });
const p38 = p.then(undefined, () => Promise.resolve(1));
const p39 = p.then(undefined, () => Promise.reject(1));
const p40 = p.then(null, undefined);
const p41 = p.then(null, null);
const p42 = p.then(null, () => 1);
const p43 = p.then(null, () => x);
const p44 = p.then(null, () => undefined);
const p45 = p.then(null, () => null);
const p46 = p.then(null, () => { });
const p47 = p.then(null, () => { throw 1; });
const p48 = p.then(null, () => Promise.resolve(1));
const p49 = p.then(null, () => Promise.reject(1));
const p50 = p.then(() => "1", undefined);
const p51 = p.then(() => "1", null);
const p52 = p.then(() => "1", () => 1);
const p53 = p.then(() => "1", () => x);
const p54 = p.then(() => "1", () => undefined);
const p55 = p.then(() => "1", () => null);
const p56 = p.then(() => "1", () => { });
const p57 = p.then(() => "1", () => { throw 1; });
const p58 = p.then(() => "1", () => Promise.resolve(1));
const p59 = p.then(() => "1", () => Promise.reject(1));
const p60 = p.then(() => x, undefined);
const p61 = p.then(() => x, null);
const p62 = p.then(() => x, () => 1);
const p63 = p.then(() => x, () => x);
const p64 = p.then(() => x, () => undefined);
const p65 = p.then(() => x, () => null);
const p66 = p.then(() => x, () => { });
const p67 = p.then(() => x, () => { throw 1; });
const p68 = p.then(() => x, () => Promise.resolve(1));
const p69 = p.then(() => x, () => Promise.reject(1));
const p70 = p.then(() => undefined, undefined);
const p71 = p.then(() => undefined, null);
const p72 = p.then(() => undefined, () => 1);
const p73 = p.then(() => undefined, () => x);
const p74 = p.then(() => undefined, () => undefined);
const p75 = p.then(() => undefined, () => null);
const p76 = p.then(() => undefined, () => { });
const p77 = p.then(() => undefined, () => { throw 1; });
const p78 = p.then(() => undefined, () => Promise.resolve(1));
const p79 = p.then(() => undefined, () => Promise.reject(1));
const p80 = p.then(() => null, undefined);
const p81 = p.then(() => null, null);
const p82 = p.then(() => null, () => 1);
const p83 = p.then(() => null, () => x);
const p84 = p.then(() => null, () => undefined);
const p85 = p.then(() => null, () => null);
const p86 = p.then(() => null, () => { });
const p87 = p.then(() => null, () => { throw 1; });
const p88 = p.then(() => null, () => Promise.resolve(1));
const p89 = p.then(() => null, () => Promise.reject(1));
const p90 = p.then(() => { }, undefined);
const p91 = p.then(() => { }, null);
const p92 = p.then(() => { }, () => 1);
const p93 = p.then(() => { }, () => x);
const p94 = p.then(() => { }, () => undefined);
const p95 = p.then(() => { }, () => null);
const p96 = p.then(() => { }, () => { });
const p97 = p.then(() => { }, () => { throw 1; });
const p98 = p.then(() => { }, () => Promise.resolve(1));
const p99 = p.then(() => { }, () => Promise.reject(1));
const pa0 = p.then(() => { throw 1; }, undefined);
const pa1 = p.then(() => { throw 1; }, null);
const pa2 = p.then(() => { throw 1; }, () => 1);
const pa3 = p.then(() => { throw 1; }, () => x);
const pa4 = p.then(() => { throw 1; }, () => undefined);
const pa5 = p.then(() => { throw 1; }, () => null);
const pa6 = p.then(() => { throw 1; }, () => { });
const pa7 = p.then(() => { throw 1; }, () => { throw 1; });
const pa8 = p.then(() => { throw 1; }, () => Promise.resolve(1));
const pa9 = p.then(() => { throw 1; }, () => Promise.reject(1));
const pb0 = p.then(() => Promise.resolve("1"), undefined);
const pb1 = p.then(() => Promise.resolve("1"), null);
const pb2 = p.then(() => Promise.resolve("1"), () => 1);
const pb3 = p.then(() => Promise.resolve("1"), () => x);
const pb4 = p.then(() => Promise.resolve("1"), () => undefined);
const pb5 = p.then(() => Promise.resolve("1"), () => null);
const pb6 = p.then(() => Promise.resolve("1"), () => { });
const pb7 = p.then(() => Promise.resolve("1"), () => { throw 1; });
const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const pc0 = p.then(() => Promise.reject("1"), undefined);
const pc1 = p.then(() => Promise.reject("1"), null);
const pc2 = p.then(() => Promise.reject("1"), () => 1);
const pc3 = p.then(() => Promise.reject("1"), () => x);
const pc4 = p.then(() => Promise.reject("1"), () => undefined);
const pc5 = p.then(() => Promise.reject("1"), () => null);
const pc6 = p.then(() => Promise.reject("1"), () => { });
const pc7 = p.then(() => Promise.reject("1"), () => { throw 1; });
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -4,7 +4,7 @@ declare class Promise<T> {
>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 22))
then<U>(success?: (value: T) => Promise<U>): Promise<U>;
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 26))
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 26))
>U : Symbol(U, Decl(promiseTypeInference.ts, 1, 9))
>success : Symbol(success, Decl(promiseTypeInference.ts, 1, 12))
>value : Symbol(value, Decl(promiseTypeInference.ts, 1, 23))
@@ -41,9 +41,9 @@ declare function convert(s: string): IPromise<number>;
var $$x = load("something").then(s => convert(s));
>$$x : Symbol($$x, Decl(promiseTypeInference.ts, 9, 3))
>load("something").then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 26))
>load("something").then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 26))
>load : Symbol(load, Decl(promiseTypeInference.ts, 5, 1))
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 26))
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 26))
>s : Symbol(s, Decl(promiseTypeInference.ts, 9, 33))
>convert : Symbol(convert, Decl(promiseTypeInference.ts, 6, 53))
>s : Symbol(s, Decl(promiseTypeInference.ts, 9, 33))
@@ -4,7 +4,7 @@ declare class Promise<T> {
>T : T
then<U>(success?: (value: T) => Promise<U>): Promise<U>;
>then : { (onfulfilled?: (value: T) => T | PromiseLike<T>, onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>; <TResult>(onfulfilled: (value: T) => T | PromiseLike<T>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>; <TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | 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 : { (onfulfilled?: (value: string) => string | PromiseLike<string>, onrejected?: (reason: any) => string | PromiseLike<string>): Promise<string>; <TResult>(onfulfilled: (value: string) => string | PromiseLike<string>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<string | TResult>; <TResult>(onfulfilled: (value: string) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: string) => Promise<U>): Promise<U>; }
>load("something") : Promise<string>
>load : (name: string) => Promise<string>
>"something" : "something"
>then : { (onfulfilled?: (value: string) => string | PromiseLike<string>, onrejected?: (reason: any) => string | PromiseLike<string>): Promise<string>; <TResult>(onfulfilled: (value: string) => string | PromiseLike<string>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<string | TResult>; <TResult>(onfulfilled: (value: string) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: string) => Promise<U>): Promise<U>; }
>s => convert(s) : (s: string) => IPromise<number>
>s : string
>convert(s) : IPromise<number>
+264 -139
View File
@@ -1,16 +1,6 @@
//// [promiseTypeStrictNull.ts]
declare var p: Promise<boolean>;
const a = p.then();
const b = p.then(b => 1);
const c = p.then(b => 1, e => 'error');
const d = p.then(b => 1, e => { });
const e = p.then(b => 1, e => { throw Error(); });
const f = p.then(b => 1, e => Promise.reject(Error()));
const g = p.catch(e => 'error');
const h = p.catch(e => { });
const i = p.catch(e => { throw Error(); });
const j = p.catch(e => Promise.reject(Error()));
declare var x: any;
async function A() {
const a = await p;
@@ -22,17 +12,15 @@ async function B() {
return 1;
}
// NOTE: This reports a "No best comment type exists among return expressions." error, and is
// ignored to get the types result for the test.
// async function C() {
// try {
// const a = await p;
// return 1;
// }
// catch (e) {
// return 'error';
// }
// }
async function C() {
try {
const a = await p;
return 1;
}
catch (e) {
return 'error';
}
}
async function D() {
try {
@@ -96,64 +84,140 @@ async function I() {
// addresses github issue #4903:
const p00 = p.catch();
const p01 = p.catch(undefined);
const p07 = p.catch(null);
const p02 = p.catch(() => 1);
const p03 = p.catch(() => {});
const p04 = p.catch(() => {throw 1});
const p05 = p.catch(() => Promise.reject(1));
const p06 = p.catch(() => Promise.resolve(1));
const p01 = p.then();
const p10 = p.then();
const p10 = p.catch(undefined);
const p11 = p.catch(null);
const p12 = p.catch(() => 1);
const p13 = p.catch(() => x);
const p14 = p.catch(() => undefined);
const p15 = p.catch(() => null);
const p16 = p.catch(() => {});
const p17 = p.catch(() => {throw 1});
const p18 = p.catch(() => Promise.reject(1));
const p19 = p.catch(() => Promise.resolve(1));
const p20 = p.then(undefined);
const p21 = p.then(() => 1);
const p22 = p.then(() => {});
const p23 = p.then(() => {throw 1});
const p24 = p.then(() => Promise.resolve(1));
const p25 = p.then(() => Promise.reject(1));
const p21 = p.then(null);
const p22 = p.then(() => 1);
const p23 = p.then(() => x);
const p24 = p.then(() => undefined);
const p25 = p.then(() => null);
const p26 = p.then(() => {});
const p27 = p.then(() => {throw 1});
const p28 = p.then(() => Promise.resolve(1));
const p29 = p.then(() => Promise.reject(1));
const p30 = p.then(undefined, undefined);
const p31 = p.then(undefined, () => 1);
const p32 = p.then(undefined, () => {});
const p33 = p.then(undefined, () => {throw 1});
const p34 = p.then(undefined, () => Promise.resolve(1));
const p35 = p.then(undefined, () => Promise.reject(1));
const p31 = p.then(undefined, null);
const p32 = p.then(undefined, () => 1);
const p33 = p.then(undefined, () => x);
const p34 = p.then(undefined, () => undefined);
const p35 = p.then(undefined, () => null);
const p36 = p.then(undefined, () => {});
const p37 = p.then(undefined, () => {throw 1});
const p38 = p.then(undefined, () => Promise.resolve(1));
const p39 = p.then(undefined, () => Promise.reject(1));
const p40 = p.then(() => "1", undefined);
const p41 = p.then(() => "1", () => 1);
const p42 = p.then(() => "1", () => {});
const p43 = p.then(() => "1", () => {throw 1});
const p44 = p.then(() => "1", () => Promise.resolve(1));
const p45 = p.then(() => "1", () => Promise.reject(1));
const p40 = p.then(null, undefined);
const p41 = p.then(null, null);
const p42 = p.then(null, () => 1);
const p43 = p.then(null, () => x);
const p44 = p.then(null, () => undefined);
const p45 = p.then(null, () => null);
const p46 = p.then(null, () => {});
const p47 = p.then(null, () => {throw 1});
const p48 = p.then(null, () => Promise.resolve(1));
const p49 = p.then(null, () => Promise.reject(1));
const p50 = p.then(() => {}, undefined);
const p51 = p.then(() => {}, () => 1);
const p52 = p.then(() => {}, () => {});
const p53 = p.then(() => {}, () => {throw 1});
const p54 = p.then(() => {}, () => Promise.resolve(1));
const p55 = p.then(() => {}, () => Promise.reject(1));
const p50 = p.then(() => "1", undefined);
const p51 = p.then(() => "1", null);
const p52 = p.then(() => "1", () => 1);
const p53 = p.then(() => "1", () => x);
const p54 = p.then(() => "1", () => undefined);
const p55 = p.then(() => "1", () => null);
const p56 = p.then(() => "1", () => {});
const p57 = p.then(() => "1", () => {throw 1});
const p58 = p.then(() => "1", () => Promise.resolve(1));
const p59 = p.then(() => "1", () => Promise.reject(1));
const p60 = p.then(() => {throw 1}, undefined);
const p61 = p.then(() => {throw 1}, () => 1);
const p62 = p.then(() => {throw 1}, () => {});
const p63 = p.then(() => {throw 1}, () => {throw 1});
const p64 = p.then(() => {throw 1}, () => Promise.resolve(1));
const p65 = p.then(() => {throw 1}, () => Promise.reject(1));
const p60 = p.then(() => x, undefined);
const p61 = p.then(() => x, null);
const p62 = p.then(() => x, () => 1);
const p63 = p.then(() => x, () => x);
const p64 = p.then(() => x, () => undefined);
const p65 = p.then(() => x, () => null);
const p66 = p.then(() => x, () => {});
const p67 = p.then(() => x, () => {throw 1});
const p68 = p.then(() => x, () => Promise.resolve(1));
const p69 = p.then(() => x, () => Promise.reject(1));
const p70 = p.then(() => Promise.resolve("1"), undefined);
const p71 = p.then(() => Promise.resolve("1"), () => 1);
const p72 = p.then(() => Promise.resolve("1"), () => {});
const p73 = p.then(() => Promise.resolve("1"), () => {throw 1});
const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const p70 = p.then(() => undefined, undefined);
const p71 = p.then(() => undefined, null);
const p72 = p.then(() => undefined, () => 1);
const p73 = p.then(() => undefined, () => x);
const p74 = p.then(() => undefined, () => undefined);
const p75 = p.then(() => undefined, () => null);
const p76 = p.then(() => undefined, () => {});
const p77 = p.then(() => undefined, () => {throw 1});
const p78 = p.then(() => undefined, () => Promise.resolve(1));
const p79 = p.then(() => undefined, () => Promise.reject(1));
const p80 = p.then(() => Promise.reject(1), undefined);
const p81 = p.then(() => Promise.reject(1), () => 1);
const p82 = p.then(() => Promise.reject(1), () => {});
const p83 = p.then(() => Promise.reject(1), () => {throw 1});
const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1));
const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1));
const p80 = p.then(() => null, undefined);
const p81 = p.then(() => null, null);
const p82 = p.then(() => null, () => 1);
const p83 = p.then(() => null, () => x);
const p84 = p.then(() => null, () => undefined);
const p85 = p.then(() => null, () => null);
const p86 = p.then(() => null, () => {});
const p87 = p.then(() => null, () => {throw 1});
const p88 = p.then(() => null, () => Promise.resolve(1));
const p89 = p.then(() => null, () => Promise.reject(1));
const p90 = p.then(() => {}, undefined);
const p91 = p.then(() => {}, null);
const p92 = p.then(() => {}, () => 1);
const p93 = p.then(() => {}, () => x);
const p94 = p.then(() => {}, () => undefined);
const p95 = p.then(() => {}, () => null);
const p96 = p.then(() => {}, () => {});
const p97 = p.then(() => {}, () => {throw 1});
const p98 = p.then(() => {}, () => Promise.resolve(1));
const p99 = p.then(() => {}, () => Promise.reject(1));
const pa0 = p.then(() => {throw 1}, undefined);
const pa1 = p.then(() => {throw 1}, null);
const pa2 = p.then(() => {throw 1}, () => 1);
const pa3 = p.then(() => {throw 1}, () => x);
const pa4 = p.then(() => {throw 1}, () => undefined);
const pa5 = p.then(() => {throw 1}, () => null);
const pa6 = p.then(() => {throw 1}, () => {});
const pa7 = p.then(() => {throw 1}, () => {throw 1});
const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1));
const pa9 = p.then(() => {throw 1}, () => Promise.reject(1));
const pb0 = p.then(() => Promise.resolve("1"), undefined);
const pb1 = p.then(() => Promise.resolve("1"), null);
const pb2 = p.then(() => Promise.resolve("1"), () => 1);
const pb3 = p.then(() => Promise.resolve("1"), () => x);
const pb4 = p.then(() => Promise.resolve("1"), () => undefined);
const pb5 = p.then(() => Promise.resolve("1"), () => null);
const pb6 = p.then(() => Promise.resolve("1"), () => {});
const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1});
const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const pc0 = p.then(() => Promise.reject("1"), undefined);
const pc1 = p.then(() => Promise.reject("1"), null);
const pc2 = p.then(() => Promise.reject("1"), () => 1);
const pc3 = p.then(() => Promise.reject("1"), () => x);
const pc4 = p.then(() => Promise.reject("1"), () => undefined);
const pc5 = p.then(() => Promise.reject("1"), () => null);
const pc6 = p.then(() => Promise.reject("1"), () => {});
const pc7 = p.then(() => Promise.reject("1"), () => {throw 1});
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
//// [promiseTypeStrictNull.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -164,16 +228,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
const a = p.then();
const b = p.then(b => 1);
const c = p.then(b => 1, e => 'error');
const d = p.then(b => 1, e => { });
const e = p.then(b => 1, e => { throw Error(); });
const f = p.then(b => 1, e => Promise.reject(Error()));
const g = p.catch(e => 'error');
const h = p.catch(e => { });
const i = p.catch(e => { throw Error(); });
const j = p.catch(e => Promise.reject(Error()));
function A() {
return __awaiter(this, void 0, void 0, function* () {
const a = yield p;
@@ -186,17 +240,17 @@ function B() {
return 1;
});
}
// NOTE: This reports a "No best comment type exists among return expressions." error, and is
// ignored to get the types result for the test.
// async function C() {
// try {
// const a = await p;
// return 1;
// }
// catch (e) {
// return 'error';
// }
// }
function C() {
return __awaiter(this, void 0, void 0, function* () {
try {
const a = yield p;
return 1;
}
catch (e) {
return 'error';
}
});
}
function D() {
return __awaiter(this, void 0, void 0, function* () {
try {
@@ -264,53 +318,124 @@ function I() {
}
// addresses github issue #4903:
const p00 = p.catch();
const p01 = p.catch(undefined);
const p07 = p.catch(null);
const p02 = p.catch(() => 1);
const p03 = p.catch(() => { });
const p04 = p.catch(() => { throw 1; });
const p05 = p.catch(() => Promise.reject(1));
const p06 = p.catch(() => Promise.resolve(1));
const p10 = p.then();
const p01 = p.then();
const p10 = p.catch(undefined);
const p11 = p.catch(null);
const p12 = p.catch(() => 1);
const p13 = p.catch(() => x);
const p14 = p.catch(() => undefined);
const p15 = p.catch(() => null);
const p16 = p.catch(() => { });
const p17 = p.catch(() => { throw 1; });
const p18 = p.catch(() => Promise.reject(1));
const p19 = p.catch(() => Promise.resolve(1));
const p20 = p.then(undefined);
const p21 = p.then(() => 1);
const p22 = p.then(() => { });
const p23 = p.then(() => { throw 1; });
const p24 = p.then(() => Promise.resolve(1));
const p25 = p.then(() => Promise.reject(1));
const p21 = p.then(null);
const p22 = p.then(() => 1);
const p23 = p.then(() => x);
const p24 = p.then(() => undefined);
const p25 = p.then(() => null);
const p26 = p.then(() => { });
const p27 = p.then(() => { throw 1; });
const p28 = p.then(() => Promise.resolve(1));
const p29 = p.then(() => Promise.reject(1));
const p30 = p.then(undefined, undefined);
const p31 = p.then(undefined, () => 1);
const p32 = p.then(undefined, () => { });
const p33 = p.then(undefined, () => { throw 1; });
const p34 = p.then(undefined, () => Promise.resolve(1));
const p35 = p.then(undefined, () => Promise.reject(1));
const p40 = p.then(() => "1", undefined);
const p41 = p.then(() => "1", () => 1);
const p42 = p.then(() => "1", () => { });
const p43 = p.then(() => "1", () => { throw 1; });
const p44 = p.then(() => "1", () => Promise.resolve(1));
const p45 = p.then(() => "1", () => Promise.reject(1));
const p50 = p.then(() => { }, undefined);
const p51 = p.then(() => { }, () => 1);
const p52 = p.then(() => { }, () => { });
const p53 = p.then(() => { }, () => { throw 1; });
const p54 = p.then(() => { }, () => Promise.resolve(1));
const p55 = p.then(() => { }, () => Promise.reject(1));
const p60 = p.then(() => { throw 1; }, undefined);
const p61 = p.then(() => { throw 1; }, () => 1);
const p62 = p.then(() => { throw 1; }, () => { });
const p63 = p.then(() => { throw 1; }, () => { throw 1; });
const p64 = p.then(() => { throw 1; }, () => Promise.resolve(1));
const p65 = p.then(() => { throw 1; }, () => Promise.reject(1));
const p70 = p.then(() => Promise.resolve("1"), undefined);
const p71 = p.then(() => Promise.resolve("1"), () => 1);
const p72 = p.then(() => Promise.resolve("1"), () => { });
const p73 = p.then(() => Promise.resolve("1"), () => { throw 1; });
const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const p80 = p.then(() => Promise.reject(1), undefined);
const p81 = p.then(() => Promise.reject(1), () => 1);
const p82 = p.then(() => Promise.reject(1), () => { });
const p83 = p.then(() => Promise.reject(1), () => { throw 1; });
const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1));
const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1));
const p31 = p.then(undefined, null);
const p32 = p.then(undefined, () => 1);
const p33 = p.then(undefined, () => x);
const p34 = p.then(undefined, () => undefined);
const p35 = p.then(undefined, () => null);
const p36 = p.then(undefined, () => { });
const p37 = p.then(undefined, () => { throw 1; });
const p38 = p.then(undefined, () => Promise.resolve(1));
const p39 = p.then(undefined, () => Promise.reject(1));
const p40 = p.then(null, undefined);
const p41 = p.then(null, null);
const p42 = p.then(null, () => 1);
const p43 = p.then(null, () => x);
const p44 = p.then(null, () => undefined);
const p45 = p.then(null, () => null);
const p46 = p.then(null, () => { });
const p47 = p.then(null, () => { throw 1; });
const p48 = p.then(null, () => Promise.resolve(1));
const p49 = p.then(null, () => Promise.reject(1));
const p50 = p.then(() => "1", undefined);
const p51 = p.then(() => "1", null);
const p52 = p.then(() => "1", () => 1);
const p53 = p.then(() => "1", () => x);
const p54 = p.then(() => "1", () => undefined);
const p55 = p.then(() => "1", () => null);
const p56 = p.then(() => "1", () => { });
const p57 = p.then(() => "1", () => { throw 1; });
const p58 = p.then(() => "1", () => Promise.resolve(1));
const p59 = p.then(() => "1", () => Promise.reject(1));
const p60 = p.then(() => x, undefined);
const p61 = p.then(() => x, null);
const p62 = p.then(() => x, () => 1);
const p63 = p.then(() => x, () => x);
const p64 = p.then(() => x, () => undefined);
const p65 = p.then(() => x, () => null);
const p66 = p.then(() => x, () => { });
const p67 = p.then(() => x, () => { throw 1; });
const p68 = p.then(() => x, () => Promise.resolve(1));
const p69 = p.then(() => x, () => Promise.reject(1));
const p70 = p.then(() => undefined, undefined);
const p71 = p.then(() => undefined, null);
const p72 = p.then(() => undefined, () => 1);
const p73 = p.then(() => undefined, () => x);
const p74 = p.then(() => undefined, () => undefined);
const p75 = p.then(() => undefined, () => null);
const p76 = p.then(() => undefined, () => { });
const p77 = p.then(() => undefined, () => { throw 1; });
const p78 = p.then(() => undefined, () => Promise.resolve(1));
const p79 = p.then(() => undefined, () => Promise.reject(1));
const p80 = p.then(() => null, undefined);
const p81 = p.then(() => null, null);
const p82 = p.then(() => null, () => 1);
const p83 = p.then(() => null, () => x);
const p84 = p.then(() => null, () => undefined);
const p85 = p.then(() => null, () => null);
const p86 = p.then(() => null, () => { });
const p87 = p.then(() => null, () => { throw 1; });
const p88 = p.then(() => null, () => Promise.resolve(1));
const p89 = p.then(() => null, () => Promise.reject(1));
const p90 = p.then(() => { }, undefined);
const p91 = p.then(() => { }, null);
const p92 = p.then(() => { }, () => 1);
const p93 = p.then(() => { }, () => x);
const p94 = p.then(() => { }, () => undefined);
const p95 = p.then(() => { }, () => null);
const p96 = p.then(() => { }, () => { });
const p97 = p.then(() => { }, () => { throw 1; });
const p98 = p.then(() => { }, () => Promise.resolve(1));
const p99 = p.then(() => { }, () => Promise.reject(1));
const pa0 = p.then(() => { throw 1; }, undefined);
const pa1 = p.then(() => { throw 1; }, null);
const pa2 = p.then(() => { throw 1; }, () => 1);
const pa3 = p.then(() => { throw 1; }, () => x);
const pa4 = p.then(() => { throw 1; }, () => undefined);
const pa5 = p.then(() => { throw 1; }, () => null);
const pa6 = p.then(() => { throw 1; }, () => { });
const pa7 = p.then(() => { throw 1; }, () => { throw 1; });
const pa8 = p.then(() => { throw 1; }, () => Promise.resolve(1));
const pa9 = p.then(() => { throw 1; }, () => Promise.reject(1));
const pb0 = p.then(() => Promise.resolve("1"), undefined);
const pb1 = p.then(() => Promise.resolve("1"), null);
const pb2 = p.then(() => Promise.resolve("1"), () => 1);
const pb3 = p.then(() => Promise.resolve("1"), () => x);
const pb4 = p.then(() => Promise.resolve("1"), () => undefined);
const pb5 = p.then(() => Promise.resolve("1"), () => null);
const pb6 = p.then(() => Promise.resolve("1"), () => { });
const pb7 = p.then(() => Promise.resolve("1"), () => { throw 1; });
const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const pc0 = p.then(() => Promise.reject("1"), undefined);
const pc1 = p.then(() => Promise.reject("1"), null);
const pc2 = p.then(() => Promise.reject("1"), () => 1);
const pc3 = p.then(() => Promise.reject("1"), () => x);
const pc4 = p.then(() => Promise.reject("1"), () => undefined);
const pc5 = p.then(() => Promise.reject("1"), () => null);
const pc6 = p.then(() => Promise.reject("1"), () => { });
const pc7 = p.then(() => Promise.reject("1"), () => { throw 1; });
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -47,12 +47,12 @@ function f2(x: T1): T2 {
var x3 = f1()
>x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3))
>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>f1() .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f1() .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1))
.then(f2, (e: Error) => {
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1))
>e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15))
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
@@ -62,7 +62,7 @@ var x3 = f1()
})
.then((x: T2) => {
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11))
>T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1))
@@ -54,14 +54,14 @@ function f2(x: T1): T2 {
var x3 = f1()
>x3 : Promise<{ __t3: string; }>
>f1() .then(f2, (e: Error) => { throw e;}) .then((x: T2) => { return { __t3: x.__t2 + "bar" };}) : Promise<{ __t3: string; }>
>f1() .then(f2, (e: Error) => { throw e;}) .then : { (onfulfilled?: (value: T2) => T2 | PromiseLike<T2>, onrejected?: (reason: any) => T2 | PromiseLike<T2>): Promise<T2>; <TResult>(onfulfilled: (value: T2) => T2 | PromiseLike<T2>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T2 | TResult>; <TResult>(onfulfilled: (value: T2) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>f1() .then(f2, (e: Error) => { throw e;}) : Promise<T2>
>f1() .then : { (onfulfilled?: (value: T1) => T1 | PromiseLike<T1>, onrejected?: (reason: any) => T1 | PromiseLike<T1>): Promise<T1>; <TResult>(onfulfilled: (value: T1) => T1 | PromiseLike<T1>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T1 | TResult>; <TResult>(onfulfilled: (value: T1) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>f1() : Promise<T1>
>f1 : () => Promise<T1>
.then(f2, (e: Error) => {
>then : { (onfulfilled?: (value: T1) => T1 | PromiseLike<T1>, onrejected?: (reason: any) => T1 | PromiseLike<T1>): Promise<T1>; <TResult>(onfulfilled: (value: T1) => T1 | PromiseLike<T1>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T1 | TResult>; <TResult>(onfulfilled: (value: T1) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(onfulfilled: (value: T1) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; }
>then : <TResult1 = T1, TResult2 = never>(onfulfilled?: (value: T1) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | 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 : { (onfulfilled?: (value: T2) => T2 | PromiseLike<T2>, onrejected?: (reason: any) => T2 | PromiseLike<T2>): Promise<T2>; <TResult>(onfulfilled: (value: T2) => T2 | PromiseLike<T2>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T2 | TResult>; <TResult>(onfulfilled: (value: T2) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(onfulfilled: (value: T2) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; }
>then : <TResult1 = T2, TResult2 = never>(onfulfilled?: (value: T2) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>(x: T2) => { return { __t3: x.__t2 + "bar" };} : (x: T2) => { __t3: string; }
>x : T2
>T2 : T2
+2 -2
View File
@@ -4,7 +4,7 @@ interface Promise<T> {
>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 18))
then<U>(success?: (value: T) => U): Promise<U>;
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 22), Decl(promises.ts, 1, 51))
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 22), Decl(promises.ts, 1, 51))
>U : Symbol(U, Decl(promises.ts, 1, 9))
>success : Symbol(success, Decl(promises.ts, 1, 12))
>value : Symbol(value, Decl(promises.ts, 1, 23))
@@ -14,7 +14,7 @@ interface Promise<T> {
>U : Symbol(U, Decl(promises.ts, 1, 9))
then<U>(success?: (value: T) => Promise<U>): Promise<U>;
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 22), Decl(promises.ts, 1, 51))
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 22), Decl(promises.ts, 1, 51))
>U : Symbol(U, Decl(promises.ts, 2, 9))
>success : Symbol(success, Decl(promises.ts, 2, 12))
>value : Symbol(value, Decl(promises.ts, 2, 23))
+2 -2
View File
@@ -4,7 +4,7 @@ interface Promise<T> {
>T : T
then<U>(success?: (value: T) => U): Promise<U>;
>then : { (onfulfilled?: (value: T) => T | PromiseLike<T>, onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>; <TResult>(onfulfilled: (value: T) => T | PromiseLike<T>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>; <TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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: 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>; }
>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 : { (onfulfilled?: (value: T) => T | PromiseLike<T>, onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>; <TResult>(onfulfilled: (value: T) => T | PromiseLike<T>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>; <TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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: 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>; }
>U : U
>success : (value: T) => Promise<U>
>value : T
@@ -4,7 +4,7 @@ interface Promise<T> {
>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 18))
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 22))
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 22))
>U : Symbol(U, Decl(promisesWithConstraints.ts, 1, 9))
>cb : Symbol(cb, Decl(promisesWithConstraints.ts, 1, 12))
>x : Symbol(x, Decl(promisesWithConstraints.ts, 1, 17))
@@ -4,7 +4,7 @@ interface Promise<T> {
>T : T
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
>then : { (onfulfilled?: (value: T) => T | PromiseLike<T>, onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>; <TResult>(onfulfilled: (value: T) => T | PromiseLike<T>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>; <TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(cb: (x: 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>(cb: (x: T) => Promise<U>): Promise<U>; }
>U : U
>cb : (x: T) => Promise<U>
>x : T
@@ -4,7 +4,7 @@ interface Promise<T> {
>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(specializationError.ts, 0, 18))
then<U>(value: T): void;
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(specializationError.ts, 0, 22))
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(specializationError.ts, 0, 22))
>U : Symbol(U, Decl(specializationError.ts, 1, 9))
>value : Symbol(value, Decl(specializationError.ts, 1, 12))
>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(specializationError.ts, 0, 18))
@@ -4,7 +4,7 @@ interface Promise<T> {
>T : T
then<U>(value: T): void;
>then : { (onfulfilled?: (value: T) => T | PromiseLike<T>, onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>; <TResult>(onfulfilled: (value: T) => T | PromiseLike<T>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>; <TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult1, TResult2>(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: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(value: T): void; }
>U : U
>value : T
>T : T
@@ -1,14 +1,21 @@
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(3,11): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(7,11): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(11,11): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(15,11): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(20,15): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(24,15): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(28,15): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(32,15): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(50,22): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(56,22): error TS2428: All declarations of 'B' must have identical type parameters.
==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts (5 errors) ====
==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts (10 errors) ====
// type parameter names are relevant when choosing whether to merge interface declarations
interface A<T> {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
x: T;
}
@@ -19,6 +26,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer
}
interface B<T,U> {
~
!!! error TS2428: All declarations of 'B' must have identical type parameters.
x: U;
}
@@ -30,6 +39,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer
module M {
interface A<T> {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
x: T;
}
@@ -40,6 +51,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer
}
interface B<T, U> {
~
!!! error TS2428: All declarations of 'B' must have identical type parameters.
x: U;
}
@@ -64,6 +77,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer
module M3 {
export interface B<T, U> {
~
!!! error TS2428: All declarations of 'B' must have identical type parameters.
x: U;
}
}
@@ -1,13 +1,18 @@
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(3,11): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(7,11): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(8,8): error TS2304: Cannot find name 'V'.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(12,15): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(16,15): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(34,22): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(40,22): error TS2428: All declarations of 'B' must have identical type parameters.
==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts (4 errors) ====
==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts (7 errors) ====
// type parameter names are relevant when choosing whether to merge interface declarations
interface B<T, U> {
~
!!! error TS2428: All declarations of 'B' must have identical type parameters.
x: U;
}
@@ -21,6 +26,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer
module M {
interface B<T, U> {
~
!!! error TS2428: All declarations of 'B' must have identical type parameters.
x: U;
}
@@ -45,6 +52,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer
module M3 {
export interface B<T, U> {
~
!!! error TS2428: All declarations of 'B' must have identical type parameters.
x: U;
}
}
@@ -1,10 +1,15 @@
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(1,11): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(5,11): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(10,15): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(14,15): error TS2428: All declarations of 'B' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(32,22): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(38,22): error TS2428: All declarations of 'A' must have identical type parameters.
==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts (3 errors) ====
==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts (6 errors) ====
interface A<T extends Date> {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
x: T;
}
@@ -16,6 +21,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDi
module M {
interface B<T extends A<Date>> {
~
!!! error TS2428: All declarations of 'B' must have identical type parameters.
x: T;
}
@@ -40,6 +47,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDi
module M3 {
export interface A<T extends Date> {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
x: T;
}
}
@@ -1,10 +1,15 @@
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(1,11): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(5,11): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(10,15): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(14,15): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(32,22): error TS2428: All declarations of 'A' must have identical type parameters.
tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(38,22): error TS2428: All declarations of 'A' must have identical type parameters.
==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts (3 errors) ====
==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts (6 errors) ====
interface A<T> {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
x: T;
}
@@ -16,6 +21,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTh
module M {
interface A<T> {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
x: T;
}
@@ -40,6 +47,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTh
module M3 {
export interface A<T> {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
x: T;
}
}
+481
View File
@@ -0,0 +1,481 @@
// @declaration: true
interface A { a: number; }
interface B { b: number; }
interface C { c: number; }
interface D { d: number; }
interface AB { a: number; b: number; }
interface BC { b: number; c: number; }
declare const a: A;
declare const b: B;
declare const c: C;
declare const d: D;
declare const ab: AB;
declare const bc: BC;
declare const x: any;
// function without type parameters
declare function f00(a?: A): A;
// no inference
f00();
f00(a);
// function with a type parameter without a default
declare function f01<T>(a?: T): T;
// inference
f01();
f01(a);
// no inference, fully supplied
f01<A>();
f01<A>(a);
// function with a type paramter with a default
declare function f02<T = A>(a?: T): T;
// inference
f02();
f02(a);
f02(b);
// no inference, fully supplied
f02<A>();
f02<A>(a);
f02<B>();
f02<B>(b);
// function with a type parameter with a default that refers to itself
declare function f03<T = T>(a?: T): T;
// inference
f03();
f03(a);
f03(b);
// no inference, fully supplied
f03<A>();
f03<A>(a);
f03<B>();
f03<B>(b);
// function with a type paramter without a default and a type parameter with a default
declare function f04<T, U = B>(a?: T, b?: U): [T, U];
// inference
f04();
f04(a);
f04(a, b);
f04(a, c);
// no inference, partially supplied
f04<A>();
f04<A>(a);
f04<A>(a, b);
// no inference, fully supplied
f04<A, B>();
f04<A, B>(a);
f04<A, B>(a, b);
f04<A, C>();
f04<A, C>(a);
f04<A, C>(a, c);
// function with a type parameter without a default and a type parameter with a default that refers to an earlier type parameter
declare function f05<T, U = T>(a?: T, b?: U): [T, U];
// inference
f05();
f05(a);
f05(a, a);
f05(a, b);
// no inference, partially supplied
f05<A>();
f05<A>(a);
f05<A>(a, a);
// no inference, fully supplied
f05<A, B>();
f05<A, B>(a);
f05<A, B>(a, b);
// function with a type parameter with a default that refers to an earlier type parameter with a default
declare function f06<T = A, U = T>(a?: T, b?: U): [T, U];
// inference
f06();
f06(a);
f06(a, a);
f06(a, b);
f06(b, a);
f06(b, b);
// no inference, partially supplied
f06<A>();
f06<A>(a);
f06<A>(a, a);
f06<B>();
f06<B>(b);
f06<B>(b, b);
// no inference, fully supplied
f06<A, B>();
f06<A, B>(a);
f06<A, B>(a, b);
f06<B, C>();
f06<B, C>(b);
f06<B, C>(b, c);
// function with a type parameter without a default and a type parameter with a default that refers to an earlier type parameter with a default
declare function f07<T, U = B, V = U>(a?: T, b?: U, c?: V): [T, U, V];
// inference
f07();
f07(a, b);
f07(a, c);
f07(a, b, b);
f07(a, b, c);
f07(a, c, b);
f07(a, c, c);
// no inference, partially supplied
f07<A>();
f07<A>(a);
f07<A>(a, b);
f07<A>(a, b, b);
f07<A, B>();
f07<A, B>(a);
f07<A, B>(a, b);
f07<A, B>(a, b, b);
f07<A, C>();
f07<A, C>(a);
f07<A, C>(a, c);
f07<A, C>(a, c, c);
// no inference, fully supplied
f07<A, B, C>();
f07<A, B, C>(a);
f07<A, B, C>(a, b);
f07<A, B, C>(a, b, c);
f07<A, C, A>();
f07<A, C, A>(a);
f07<A, C, D>(a, c);
f07<A, C, D>(a, c, d);
// function with a type parameter with a default that refers to an earlier type parameter with a constraint
declare function f08<T extends A, U = T>(a?: T, b?: U): [T, U];
// inference
f08();
f08(a);
f08(a, a);
f08(a, b);
// no inference, partially supplied
f08<A>();
f08<A>(a);
f08<A>(a, a);
// no inference, fully supplied
f08<A, B>();
f08<A, B>(a);
f08<A, B>(a, b);
// function with a type parameter with a constraint and a default that refers to an earlier type parameter
declare function f09<T, U extends T = T>(a?: T, b?: U): [T, U];
// inference
f09();
f09(a);
f09(a, a);
f09(a, ab);
// no inference, partially supplied
f09<A>();
f09<A>(a);
f09<A>(a, a);
f09<A>(a, ab);
// no inference, fully supplied
f09<A, AB>();
f09<A, AB>(a);
f09<A, AB>(a, ab);
// function with a type parameter with a constraint and a default that refers to an earlier type parameter with a constraint
declare function f10<T extends A, U extends T = T>(a?: T, b?: U): [T, U];
// inference
f10();
f10(a);
f10(a, a);
f10(a, ab);
// no inference, partially supplied
f10<A>();
f10<A>(a);
f10<A>(a, a);
f10<A>(a, ab);
// no inference, fully supplied
f10<A, A>();
f10<A, A>(a);
f10<A, A>(a, a);
f10<A, A>(a, ab);
f10<A, AB>();
f10<A, AB>(a);
f10<A, AB>(a, ab);
// function with a type parameter with a default that refers to an earier type parameter in a union
declare function f11<T, U = T | B>(a?: T, b?: U): [T, U];
// inference
f11();
f11(a);
f11(a, a);
f11(a, b);
f11(a, c);
// no inference, partially supplied
f11<A>();
f11<A>(a);
f11<A>(a, a);
f11<A>(a, b);
// no inference, fully supplied
f11<A, C>();
f11<A, C>(a);
f11<A, C>(a, c);
// function with a type parameter with a default that refers to an earlier type parameter in an intersection
declare function f12<T, U = T & B>(a?: T, b?: U): [T, U];
// inference
f12();
f12(a);
f12(a, a);
f12(a, b);
f12(a, c);
// no inference, partially supplied
f12<A>();
f12<A>(a);
f12<A>(a, ab);
// no inference, fully supplied
f12<A, C>();
f12<A, C>(a);
f12<A, C>(a, c);
// function with a type parameter with a default that refers to a later type parameter with a default
declare function f13<T = U, U = B>(a?: T, b?: U): [T, U];
// inference
f13();
f13(a);
f13(a, b);
f13(a, c);
// no inference, partially supplied
f13<A>();
f13<A>(a);
f13<A>(a, b);
// no inference, fully supplied
f13<A, C>();
f13<A, C>(a);
f13<A, C>(a, c);
f13<A, C>(a, c);
// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default
declare function f14<T, U = V, V = C>(a?: T, b?: U, c?: V): [T, U, V];
// inference
f14();
f14(a);
f14(a, b);
f14(a, b, c);
f14(a, b, d);
// no inference, partially supplied
f14<A>();
f14<A>(a);
f14<A>(a, b);
f14<A>(a, b, c);
f14<A, B>();
f14<A, B>(a);
f14<A, B>(a, b);
f14<A, B>(a, b, c);
// no inference fully supplied
f14<A, B, D>();
f14<A, B, D>(a);
f14<A, B, D>(a, b);
f14<A, B, D>(a, b, d);
// function with two type parameters with defaults that mutually refer to each other
declare function f15<T = U, U = T>(a?: T, b?: U): [T, U];
// inference
f15();
f15(a);
f15(a, b);
// no inference, partially supplied
f15<A>();
f15<A>(a);
f15<A>(a, a);
// no inference, fully supplied
f15<A, B>();
f15<A, B>(a);
f15<A, B>(a, b);
// function with a type parameter without a default and two type parameters with defaults that mutually refer to each other
declare function f16<T, U = V, V = U>(a?: T, b?: U, c?: V): [T, U, V];
// no inference
f16();
f16(a);
f16(a, b);
f16(a, b, b);
// no inference, partially supplied
f16<A>();
f16<A>(a);
f16<A>(a, b);
f16<A>(a, b, b);
f16<A, B>();
f16<A, B>(a);
f16<A, B>(a, b);
f16<A, B>(a, b, b);
// no inference, fully supplied
f16<A, B, D>();
f16<A, B, D>(a);
f16<A, B, D>(a, b);
f16<A, B, D>(a, b, d);
// function with a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in a union
declare function f17<T = U, U = T | B>(a?: T, b?: U): [T, U];
// inference
f17();
f17(a);
f17(a, a);
f17(a, b);
f17(a, c);
// no inference, partially supplied
f17<A>();
f17<A>(a);
f17<A>(a, a);
f17<A>(a, b);
// no inference, fully supplied
f17<A, C>();
f17<A, C>(a);
f17<A, C>(a, c);
// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in a union
declare function f18<T, U = V, V = U | C>(a?: T, b?: U, c?: V): [T, U, V];
// inference
f18();
f18(a);
f18(a, b);
f18(a, b, b);
f18(a, b, c);
// no inference, partially supplied
f18<A>();
f18<A>(a);
f18<A>(a, b);
f18<A>(a, b, b);
f18<A>(a, b, c);
f18<A, B>();
f18<A, B>(a);
f18<A, B>(a, b);
f18<A, B>(a, b, b);
f18<A, B>(a, b, c);
// no inference, fully supplied
f18<A, B, D>();
f18<A, B, D>(a);
f18<A, B, D>(a, b);
f18<A, B, D>(a, b, d);
// function with a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in an intersection
declare function f19<T = U, U = T & B>(a?: T, b?: U): [T, U];
// inference
f19();
f19(a);
f19(a, a);
f19(a, b);
f19(a, ab);
f19(a, c);
// no inference, partially supplied
f19<A>();
f19<A>(a);
f19<A>(a, ab);
// no inference, fully supplied
f19<A, C>();
f19<A, C>(a);
f19<A, C>(a, c);
// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in an intersection
declare function f20<T, U = V, V = U & C>(a?: T, b?: U, c?: V): [T, U, V];
// inference
f20();
f20(a);
f20(a, b);
f20(a, b, c);
// no inference, partially supplied
f20<A>();
f20<A>(a);
f20<A>(a, b);
f20<A>(a, b, bc);
f20<A, B>();
f20<A, B>(a);
f20<A, B>(a, b);
f20<A, B>(a, b, bc);
// no inference, fully supplied
f20<A, B, D>();
f20<A, B, D>(a);
f20<A, B, D>(a, b);
f20<A, B, D>(a, b, d);
interface i00<T = number> { a: T; }
const i00c00 = (<i00>x).a;
const i00c01 = (<i00<number>>x).a;
interface i01<T, U = T> { a: [T, U]; }
const i01c00 = (<i01<number>>x).a;
const i01c01 = (<i01<number, string>>x).a;
interface i02<T extends number, U = T> { a: [T, U]; }
const i02c00 = (<i02<number>>x).a;
const i02c01 = (<i02<1>>x).a;
const i02c02 = (<i02<number, number>>x).a;
const i02c03 = (<i02<1, number>>x).a;
const i02c04 = (<i02<number, 1>>x).a;
interface i03<T extends number, U extends T = T> { a: [T, U]; }
const i03c00 = (<i03<number>>x).a;
const i03c01 = (<i03<1>>x).a;
const i03c02 = (<i03<number, number>>x).a;
const i03c03 = (<i03<1, 1>>x).a;
const i03c04 = (<i03<number, 1>>x).a;
interface i04 {}
interface i04<T> {}
interface i04<T = number> {}
interface i04<T = number, U = string> {}
interface i05<T = T> { a: T; }
const i05c00 = (<i05>x).a;
const i05c01 = (<i05<number>>x).a;
interface i06<T = U, U = T> { a: [T, U]; }
const i06c00 = (<i06>x).a;
const i06c01 = (<i06<number>>x).a;
const i06c02 = (<i06<number, string>>x).a;
interface i07 { a: A; }
interface i07<A = number> { b: A; }
const i07c00 = (<i07>x).a;
const i07c01 = (<i07>x).b;
const i07c02 = (<i07<B>>x).a;
const i07c03 = (<i07<B>>x).b;
interface Base01<T> { a: T; }
interface Base01Constructor { new <T = number>(a?: T): Base01<T>; }
declare const Base01: Base01Constructor;
const Base01c00 = new Base01();
const Base01c01 = new Base01(1);
const Base01c02 = new Base01<number>();
const Base01c03 = new Base01<number>(1);
declare class Derived01<T> extends Base01<T> { }
const Derived01c00 = new Derived01();
const Derived01c01 = new Derived01(1);
const Derived01c02 = new Derived01<number>();
const Derived01c03 = new Derived01<number>(1);
declare class Derived02<T = string> extends Base01<T> { }
const Derived02c00 = new Derived02();
const Derived02c01 = new Derived02(1);
const Derived02c02 = new Derived02<number>();
const Derived02c03 = new Derived02<number>(1);
type t00<T = number> = { a: T; }
const t00c00 = (<t00>x).a;
const t00c01 = (<t00<number>>x).a;
type t01<T, U = T> = { a: [T, U]; }
const t01c00 = (<t01<number>>x).a;
const t01c01 = (<t01<number, string>>x).a;
type t02<T extends number, U = T> = { a: [T, U]; }
const t02c00 = (<t02<number>>x).a;
const t02c01 = (<t02<1>>x).a;
const t02c02 = (<t02<number, number>>x).a;
const t02c03 = (<t02<1, number>>x).a;
const t02c04 = (<t02<number, 1>>x).a;
type t03<T extends number, U extends T = T> = { a: [T, U]; }
const t03c00 = (<t03<number>>x).a;
const t03c01 = (<t03<1>>x).a;
const t03c02 = (<t03<number, number>>x).a;
const t03c03 = (<t03<1, 1>>x).a;
const t03c04 = (<t03<number, 1>>x).a;
@@ -0,0 +1,41 @@
// @declaration: true
declare const x: any;
declare function f03<T extends string = number>(): void; // error
declare function f04<T extends string, U extends number = T>(): void; // error
declare function f05<T, U extends number = T>(): void; // error
declare function f06<T, U extends T = number>(): void; // error
declare function f11<T, U, V = number>(): void;
f11(); // ok
f11<1>(); // error
f11<1, 2>(); // ok
f11<1, 2, 3>(); // ok
f11<1, 2, 3, 4>(); // error
declare function f12<T, U = T>(a?: U): void;
f12<number>(); // ok
f12<number>("a"); // error
interface i00<T> { } // ok
interface i00<U = number> { } // error
interface i01<T = number> { } // ok
interface i01<T = string> { } // error
interface i04<T = number, U> { } // error
interface i05<T extends string = number> { } // error
interface i06<T extends string, U extends number = T> { } // error
interface i07<T, U extends number = T> { } // error
interface i08<T, U extends T = number> { } // error
interface i09<T, U, V = number> { }
type i09t00 = i09; // error
type i09t01 = i09<1>; // error
type i09t02 = i09<1, 2>; // ok
type i09t03 = i09<1, 2, 3>; // ok
type i09t04 = i09<1, 2, 3, 4>; // error
interface i10 { x: T; } // error
interface i10<T = number> {}
+133 -70
View File
@@ -1,16 +1,6 @@
// @target: es6
declare var p: Promise<boolean>;
const a = p.then();
const b = p.then(b => 1);
const c = p.then(b => 1, e => 'error');
const d = p.then(b => 1, e => { });
const e = p.then(b => 1, e => { throw Error(); });
const f = p.then(b => 1, e => Promise.reject(Error()));
const g = p.catch(e => 'error');
const h = p.catch(e => { });
const i = p.catch(e => { throw Error(); });
const j = p.catch(e => Promise.reject(Error()));
declare var x: any;
async function A() {
const a = await p;
@@ -22,17 +12,15 @@ async function B() {
return 1;
}
// NOTE: This reports a "No best comment type exists among return expressions." error, and is
// ignored to get the types result for the test.
// async function C() {
// try {
// const a = await p;
// return 1;
// }
// catch (e) {
// return 'error';
// }
// }
async function C() {
try {
const a = await p;
return 1;
}
catch (e) {
return 'error';
}
}
async function D() {
try {
@@ -96,61 +84,136 @@ async function I() {
// addresses github issue #4903:
const p00 = p.catch();
const p01 = p.catch(undefined);
const p07 = p.catch(null);
const p02 = p.catch(() => 1);
const p03 = p.catch(() => {});
const p04 = p.catch(() => {throw 1});
const p05 = p.catch(() => Promise.reject(1));
const p06 = p.catch(() => Promise.resolve(1));
const p01 = p.then();
const p10 = p.then();
const p10 = p.catch(undefined);
const p11 = p.catch(null);
const p12 = p.catch(() => 1);
const p13 = p.catch(() => x);
const p14 = p.catch(() => undefined);
const p15 = p.catch(() => null);
const p16 = p.catch(() => {});
const p17 = p.catch(() => {throw 1});
const p18 = p.catch(() => Promise.reject(1));
const p19 = p.catch(() => Promise.resolve(1));
const p20 = p.then(undefined);
const p21 = p.then(() => 1);
const p22 = p.then(() => {});
const p23 = p.then(() => {throw 1});
const p24 = p.then(() => Promise.resolve(1));
const p25 = p.then(() => Promise.reject(1));
const p21 = p.then(null);
const p22 = p.then(() => 1);
const p23 = p.then(() => x);
const p24 = p.then(() => undefined);
const p25 = p.then(() => null);
const p26 = p.then(() => {});
const p27 = p.then(() => {throw 1});
const p28 = p.then(() => Promise.resolve(1));
const p29 = p.then(() => Promise.reject(1));
const p30 = p.then(undefined, undefined);
const p31 = p.then(undefined, () => 1);
const p32 = p.then(undefined, () => {});
const p33 = p.then(undefined, () => {throw 1});
const p34 = p.then(undefined, () => Promise.resolve(1));
const p35 = p.then(undefined, () => Promise.reject(1));
const p31 = p.then(undefined, null);
const p32 = p.then(undefined, () => 1);
const p33 = p.then(undefined, () => x);
const p34 = p.then(undefined, () => undefined);
const p35 = p.then(undefined, () => null);
const p36 = p.then(undefined, () => {});
const p37 = p.then(undefined, () => {throw 1});
const p38 = p.then(undefined, () => Promise.resolve(1));
const p39 = p.then(undefined, () => Promise.reject(1));
const p40 = p.then(() => "1", undefined);
const p41 = p.then(() => "1", () => 1);
const p42 = p.then(() => "1", () => {});
const p43 = p.then(() => "1", () => {throw 1});
const p44 = p.then(() => "1", () => Promise.resolve(1));
const p45 = p.then(() => "1", () => Promise.reject(1));
const p40 = p.then(null, undefined);
const p41 = p.then(null, null);
const p42 = p.then(null, () => 1);
const p43 = p.then(null, () => x);
const p44 = p.then(null, () => undefined);
const p45 = p.then(null, () => null);
const p46 = p.then(null, () => {});
const p47 = p.then(null, () => {throw 1});
const p48 = p.then(null, () => Promise.resolve(1));
const p49 = p.then(null, () => Promise.reject(1));
const p50 = p.then(() => {}, undefined);
const p51 = p.then(() => {}, () => 1);
const p52 = p.then(() => {}, () => {});
const p53 = p.then(() => {}, () => {throw 1});
const p54 = p.then(() => {}, () => Promise.resolve(1));
const p55 = p.then(() => {}, () => Promise.reject(1));
const p50 = p.then(() => "1", undefined);
const p51 = p.then(() => "1", null);
const p52 = p.then(() => "1", () => 1);
const p53 = p.then(() => "1", () => x);
const p54 = p.then(() => "1", () => undefined);
const p55 = p.then(() => "1", () => null);
const p56 = p.then(() => "1", () => {});
const p57 = p.then(() => "1", () => {throw 1});
const p58 = p.then(() => "1", () => Promise.resolve(1));
const p59 = p.then(() => "1", () => Promise.reject(1));
const p60 = p.then(() => {throw 1}, undefined);
const p61 = p.then(() => {throw 1}, () => 1);
const p62 = p.then(() => {throw 1}, () => {});
const p63 = p.then(() => {throw 1}, () => {throw 1});
const p64 = p.then(() => {throw 1}, () => Promise.resolve(1));
const p65 = p.then(() => {throw 1}, () => Promise.reject(1));
const p60 = p.then(() => x, undefined);
const p61 = p.then(() => x, null);
const p62 = p.then(() => x, () => 1);
const p63 = p.then(() => x, () => x);
const p64 = p.then(() => x, () => undefined);
const p65 = p.then(() => x, () => null);
const p66 = p.then(() => x, () => {});
const p67 = p.then(() => x, () => {throw 1});
const p68 = p.then(() => x, () => Promise.resolve(1));
const p69 = p.then(() => x, () => Promise.reject(1));
const p70 = p.then(() => Promise.resolve("1"), undefined);
const p71 = p.then(() => Promise.resolve("1"), () => 1);
const p72 = p.then(() => Promise.resolve("1"), () => {});
const p73 = p.then(() => Promise.resolve("1"), () => {throw 1});
const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const p70 = p.then(() => undefined, undefined);
const p71 = p.then(() => undefined, null);
const p72 = p.then(() => undefined, () => 1);
const p73 = p.then(() => undefined, () => x);
const p74 = p.then(() => undefined, () => undefined);
const p75 = p.then(() => undefined, () => null);
const p76 = p.then(() => undefined, () => {});
const p77 = p.then(() => undefined, () => {throw 1});
const p78 = p.then(() => undefined, () => Promise.resolve(1));
const p79 = p.then(() => undefined, () => Promise.reject(1));
const p80 = p.then(() => Promise.reject(1), undefined);
const p81 = p.then(() => Promise.reject(1), () => 1);
const p82 = p.then(() => Promise.reject(1), () => {});
const p83 = p.then(() => Promise.reject(1), () => {throw 1});
const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1));
const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1));
const p80 = p.then(() => null, undefined);
const p81 = p.then(() => null, null);
const p82 = p.then(() => null, () => 1);
const p83 = p.then(() => null, () => x);
const p84 = p.then(() => null, () => undefined);
const p85 = p.then(() => null, () => null);
const p86 = p.then(() => null, () => {});
const p87 = p.then(() => null, () => {throw 1});
const p88 = p.then(() => null, () => Promise.resolve(1));
const p89 = p.then(() => null, () => Promise.reject(1));
const p90 = p.then(() => {}, undefined);
const p91 = p.then(() => {}, null);
const p92 = p.then(() => {}, () => 1);
const p93 = p.then(() => {}, () => x);
const p94 = p.then(() => {}, () => undefined);
const p95 = p.then(() => {}, () => null);
const p96 = p.then(() => {}, () => {});
const p97 = p.then(() => {}, () => {throw 1});
const p98 = p.then(() => {}, () => Promise.resolve(1));
const p99 = p.then(() => {}, () => Promise.reject(1));
const pa0 = p.then(() => {throw 1}, undefined);
const pa1 = p.then(() => {throw 1}, null);
const pa2 = p.then(() => {throw 1}, () => 1);
const pa3 = p.then(() => {throw 1}, () => x);
const pa4 = p.then(() => {throw 1}, () => undefined);
const pa5 = p.then(() => {throw 1}, () => null);
const pa6 = p.then(() => {throw 1}, () => {});
const pa7 = p.then(() => {throw 1}, () => {throw 1});
const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1));
const pa9 = p.then(() => {throw 1}, () => Promise.reject(1));
const pb0 = p.then(() => Promise.resolve("1"), undefined);
const pb1 = p.then(() => Promise.resolve("1"), null);
const pb2 = p.then(() => Promise.resolve("1"), () => 1);
const pb3 = p.then(() => Promise.resolve("1"), () => x);
const pb4 = p.then(() => Promise.resolve("1"), () => undefined);
const pb5 = p.then(() => Promise.resolve("1"), () => null);
const pb6 = p.then(() => Promise.resolve("1"), () => {});
const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1});
const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const pc0 = p.then(() => Promise.reject("1"), undefined);
const pc1 = p.then(() => Promise.reject("1"), null);
const pc2 = p.then(() => Promise.reject("1"), () => 1);
const pc3 = p.then(() => Promise.reject("1"), () => x);
const pc4 = p.then(() => Promise.reject("1"), () => undefined);
const pc5 = p.then(() => Promise.reject("1"), () => null);
const pc6 = p.then(() => Promise.reject("1"), () => {});
const pc7 = p.then(() => Promise.reject("1"), () => {throw 1});
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
+133 -70
View File
@@ -1,17 +1,7 @@
// @target: es6
// @strictNullChecks: true
declare var p: Promise<boolean>;
const a = p.then();
const b = p.then(b => 1);
const c = p.then(b => 1, e => 'error');
const d = p.then(b => 1, e => { });
const e = p.then(b => 1, e => { throw Error(); });
const f = p.then(b => 1, e => Promise.reject(Error()));
const g = p.catch(e => 'error');
const h = p.catch(e => { });
const i = p.catch(e => { throw Error(); });
const j = p.catch(e => Promise.reject(Error()));
declare var x: any;
async function A() {
const a = await p;
@@ -23,17 +13,15 @@ async function B() {
return 1;
}
// NOTE: This reports a "No best comment type exists among return expressions." error, and is
// ignored to get the types result for the test.
// async function C() {
// try {
// const a = await p;
// return 1;
// }
// catch (e) {
// return 'error';
// }
// }
async function C() {
try {
const a = await p;
return 1;
}
catch (e) {
return 'error';
}
}
async function D() {
try {
@@ -97,61 +85,136 @@ async function I() {
// addresses github issue #4903:
const p00 = p.catch();
const p01 = p.catch(undefined);
const p07 = p.catch(null);
const p02 = p.catch(() => 1);
const p03 = p.catch(() => {});
const p04 = p.catch(() => {throw 1});
const p05 = p.catch(() => Promise.reject(1));
const p06 = p.catch(() => Promise.resolve(1));
const p01 = p.then();
const p10 = p.then();
const p10 = p.catch(undefined);
const p11 = p.catch(null);
const p12 = p.catch(() => 1);
const p13 = p.catch(() => x);
const p14 = p.catch(() => undefined);
const p15 = p.catch(() => null);
const p16 = p.catch(() => {});
const p17 = p.catch(() => {throw 1});
const p18 = p.catch(() => Promise.reject(1));
const p19 = p.catch(() => Promise.resolve(1));
const p20 = p.then(undefined);
const p21 = p.then(() => 1);
const p22 = p.then(() => {});
const p23 = p.then(() => {throw 1});
const p24 = p.then(() => Promise.resolve(1));
const p25 = p.then(() => Promise.reject(1));
const p21 = p.then(null);
const p22 = p.then(() => 1);
const p23 = p.then(() => x);
const p24 = p.then(() => undefined);
const p25 = p.then(() => null);
const p26 = p.then(() => {});
const p27 = p.then(() => {throw 1});
const p28 = p.then(() => Promise.resolve(1));
const p29 = p.then(() => Promise.reject(1));
const p30 = p.then(undefined, undefined);
const p31 = p.then(undefined, () => 1);
const p32 = p.then(undefined, () => {});
const p33 = p.then(undefined, () => {throw 1});
const p34 = p.then(undefined, () => Promise.resolve(1));
const p35 = p.then(undefined, () => Promise.reject(1));
const p31 = p.then(undefined, null);
const p32 = p.then(undefined, () => 1);
const p33 = p.then(undefined, () => x);
const p34 = p.then(undefined, () => undefined);
const p35 = p.then(undefined, () => null);
const p36 = p.then(undefined, () => {});
const p37 = p.then(undefined, () => {throw 1});
const p38 = p.then(undefined, () => Promise.resolve(1));
const p39 = p.then(undefined, () => Promise.reject(1));
const p40 = p.then(() => "1", undefined);
const p41 = p.then(() => "1", () => 1);
const p42 = p.then(() => "1", () => {});
const p43 = p.then(() => "1", () => {throw 1});
const p44 = p.then(() => "1", () => Promise.resolve(1));
const p45 = p.then(() => "1", () => Promise.reject(1));
const p40 = p.then(null, undefined);
const p41 = p.then(null, null);
const p42 = p.then(null, () => 1);
const p43 = p.then(null, () => x);
const p44 = p.then(null, () => undefined);
const p45 = p.then(null, () => null);
const p46 = p.then(null, () => {});
const p47 = p.then(null, () => {throw 1});
const p48 = p.then(null, () => Promise.resolve(1));
const p49 = p.then(null, () => Promise.reject(1));
const p50 = p.then(() => {}, undefined);
const p51 = p.then(() => {}, () => 1);
const p52 = p.then(() => {}, () => {});
const p53 = p.then(() => {}, () => {throw 1});
const p54 = p.then(() => {}, () => Promise.resolve(1));
const p55 = p.then(() => {}, () => Promise.reject(1));
const p50 = p.then(() => "1", undefined);
const p51 = p.then(() => "1", null);
const p52 = p.then(() => "1", () => 1);
const p53 = p.then(() => "1", () => x);
const p54 = p.then(() => "1", () => undefined);
const p55 = p.then(() => "1", () => null);
const p56 = p.then(() => "1", () => {});
const p57 = p.then(() => "1", () => {throw 1});
const p58 = p.then(() => "1", () => Promise.resolve(1));
const p59 = p.then(() => "1", () => Promise.reject(1));
const p60 = p.then(() => {throw 1}, undefined);
const p61 = p.then(() => {throw 1}, () => 1);
const p62 = p.then(() => {throw 1}, () => {});
const p63 = p.then(() => {throw 1}, () => {throw 1});
const p64 = p.then(() => {throw 1}, () => Promise.resolve(1));
const p65 = p.then(() => {throw 1}, () => Promise.reject(1));
const p60 = p.then(() => x, undefined);
const p61 = p.then(() => x, null);
const p62 = p.then(() => x, () => 1);
const p63 = p.then(() => x, () => x);
const p64 = p.then(() => x, () => undefined);
const p65 = p.then(() => x, () => null);
const p66 = p.then(() => x, () => {});
const p67 = p.then(() => x, () => {throw 1});
const p68 = p.then(() => x, () => Promise.resolve(1));
const p69 = p.then(() => x, () => Promise.reject(1));
const p70 = p.then(() => Promise.resolve("1"), undefined);
const p71 = p.then(() => Promise.resolve("1"), () => 1);
const p72 = p.then(() => Promise.resolve("1"), () => {});
const p73 = p.then(() => Promise.resolve("1"), () => {throw 1});
const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const p70 = p.then(() => undefined, undefined);
const p71 = p.then(() => undefined, null);
const p72 = p.then(() => undefined, () => 1);
const p73 = p.then(() => undefined, () => x);
const p74 = p.then(() => undefined, () => undefined);
const p75 = p.then(() => undefined, () => null);
const p76 = p.then(() => undefined, () => {});
const p77 = p.then(() => undefined, () => {throw 1});
const p78 = p.then(() => undefined, () => Promise.resolve(1));
const p79 = p.then(() => undefined, () => Promise.reject(1));
const p80 = p.then(() => Promise.reject(1), undefined);
const p81 = p.then(() => Promise.reject(1), () => 1);
const p82 = p.then(() => Promise.reject(1), () => {});
const p83 = p.then(() => Promise.reject(1), () => {throw 1});
const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1));
const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1));
const p80 = p.then(() => null, undefined);
const p81 = p.then(() => null, null);
const p82 = p.then(() => null, () => 1);
const p83 = p.then(() => null, () => x);
const p84 = p.then(() => null, () => undefined);
const p85 = p.then(() => null, () => null);
const p86 = p.then(() => null, () => {});
const p87 = p.then(() => null, () => {throw 1});
const p88 = p.then(() => null, () => Promise.resolve(1));
const p89 = p.then(() => null, () => Promise.reject(1));
const p90 = p.then(() => {}, undefined);
const p91 = p.then(() => {}, null);
const p92 = p.then(() => {}, () => 1);
const p93 = p.then(() => {}, () => x);
const p94 = p.then(() => {}, () => undefined);
const p95 = p.then(() => {}, () => null);
const p96 = p.then(() => {}, () => {});
const p97 = p.then(() => {}, () => {throw 1});
const p98 = p.then(() => {}, () => Promise.resolve(1));
const p99 = p.then(() => {}, () => Promise.reject(1));
const pa0 = p.then(() => {throw 1}, undefined);
const pa1 = p.then(() => {throw 1}, null);
const pa2 = p.then(() => {throw 1}, () => 1);
const pa3 = p.then(() => {throw 1}, () => x);
const pa4 = p.then(() => {throw 1}, () => undefined);
const pa5 = p.then(() => {throw 1}, () => null);
const pa6 = p.then(() => {throw 1}, () => {});
const pa7 = p.then(() => {throw 1}, () => {throw 1});
const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1));
const pa9 = p.then(() => {throw 1}, () => Promise.reject(1));
const pb0 = p.then(() => Promise.resolve("1"), undefined);
const pb1 = p.then(() => Promise.resolve("1"), null);
const pb2 = p.then(() => Promise.resolve("1"), () => 1);
const pb3 = p.then(() => Promise.resolve("1"), () => x);
const pb4 = p.then(() => Promise.resolve("1"), () => undefined);
const pb5 = p.then(() => Promise.resolve("1"), () => null);
const pb6 = p.then(() => Promise.resolve("1"), () => {});
const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1});
const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1));
const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1));
const pc0 = p.then(() => Promise.reject("1"), undefined);
const pc1 = p.then(() => Promise.reject("1"), null);
const pc2 = p.then(() => Promise.reject("1"), () => 1);
const pc3 = p.then(() => Promise.reject("1"), () => x);
const pc4 = p.then(() => Promise.reject("1"), () => undefined);
const pc5 = p.then(() => Promise.reject("1"), () => null);
const pc6 = p.then(() => Promise.reject("1"), () => {});
const pc7 = p.then(() => Promise.reject("1"), () => {throw 1});
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));