Simplify generic function call error reporting (#16439)

* Simplify error reporting for generic functions

* Accept new baselines

* Fix fourslash tests
This commit is contained in:
Anders Hejlsberg
2017-06-13 11:43:13 -07:00
committed by Mohamed Hegazy
parent 9cd04e06fd
commit 31f0814d4a
48 changed files with 1371 additions and 678 deletions
+52 -172
View File
@@ -8397,10 +8397,6 @@ namespace ts {
return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1);
}
function checkTypeSubtypeOf(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean {
return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain);
}
function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean {
return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain);
}
@@ -9844,13 +9840,6 @@ namespace ts {
return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1;
}
function isSupertypeOfEach(candidate: Type, types: Type[]): boolean {
for (const t of types) {
if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false;
}
return true;
}
function literalTypesWithSameBaseType(types: Type[]): boolean {
let commonBaseType: Type;
for (const t of types) {
@@ -9865,11 +9854,13 @@ namespace ts {
return true;
}
// When the candidate types are all literal types with the same base type, the common
// supertype is a union of those literal types. Otherwise, the common supertype is the
// first type that is a supertype of each of the other types.
// When the candidate types are all literal types with the same base type, return a union
// of those literal types. Otherwise, return the leftmost type for which no type to the
// right is a supertype.
function getSupertypeOrUnion(types: Type[]): Type {
return literalTypesWithSameBaseType(types) ? getUnionType(types) : forEach(types, t => isSupertypeOfEach(t, types) ? t : undefined);
return literalTypesWithSameBaseType(types) ?
getUnionType(types) :
reduceLeft(types, (s, t) => isTypeSubtypeOf(s, t) ? t : s);
}
function getCommonSupertype(types: Type[]): Type {
@@ -9877,52 +9868,9 @@ namespace ts {
return getSupertypeOrUnion(types);
}
const primaryTypes = filter(types, t => !(t.flags & TypeFlags.Nullable));
if (!primaryTypes.length) {
return getUnionType(types, /*subtypeReduction*/ true);
}
const supertype = getSupertypeOrUnion(primaryTypes);
return supertype && getNullableType(supertype, getFalsyFlagsOfTypes(types) & TypeFlags.Nullable);
}
function reportNoCommonSupertypeError(types: Type[], errorLocation: Node, errorMessageChainHead: DiagnosticMessageChain): void {
// The downfallType/bestSupertypeDownfallType is the first type that caused a particular candidate
// to not be the common supertype. So if it weren't for this one downfallType (and possibly others),
// the type in question could have been the common supertype.
let bestSupertype: Type;
let bestSupertypeDownfallType: Type;
let bestSupertypeScore = 0;
for (let i = 0; i < types.length; i++) {
let score = 0;
let downfallType: Type = undefined;
for (let j = 0; j < types.length; j++) {
if (isTypeSubtypeOf(types[j], types[i])) {
score++;
}
else if (!downfallType) {
downfallType = types[j];
}
}
Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType");
if (score > bestSupertypeScore) {
bestSupertype = types[i];
bestSupertypeDownfallType = downfallType;
bestSupertypeScore = score;
}
// types.length - 1 is the maximum score, given that getCommonSupertype returned false
if (bestSupertypeScore === types.length - 1) {
break;
}
}
// In the following errors, the {1} slot is before the {0} slot because checkTypeSubtypeOf supplies the
// subtype as the first argument to the error
checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation,
Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0,
errorMessageChainHead);
return primaryTypes.length ?
getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & TypeFlags.Nullable) :
getUnionType(types, /*subtypeReduction*/ true);
}
function isArrayType(type: Type): boolean {
@@ -10631,7 +10579,6 @@ namespace ts {
function getInferredType(context: InferenceContext, index: number): Type {
const inference = context.inferences[index];
let inferredType = inference.inferredType;
let inferenceSucceeded: boolean;
if (!inferredType) {
if (inference.candidates) {
// We widen inferred literal types if
@@ -10647,53 +10594,40 @@ namespace ts {
// for inferences coming from return types in order to avoid common supertype failures.
const unionOrSuperType = context.flags & InferenceFlags.InferUnionTypes || inference.priority & InferencePriority.ReturnType ?
getUnionType(baseCandidates, /*subtypeReduction*/ true) : getCommonSupertype(baseCandidates);
inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType;
inferenceSucceeded = !!unionOrSuperType;
inferredType = getWidenedType(unionOrSuperType);
}
else if (context.flags & InferenceFlags.NoDefault) {
// We use silentNeverType as the wildcard that signals no inferences.
inferredType = silentNeverType;
}
else {
if (context.flags & InferenceFlags.NoDefault) {
// We use silentNeverType as the wildcard that signals no inferences.
inferredType = silentNeverType;
// 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.
const defaultType = getDefaultFromTypeParameter(inference.typeParameter);
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),
context));
}
else {
// 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.
const defaultType = getDefaultFromTypeParameter(inference.typeParameter);
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),
context));
}
else {
inferredType = context.flags & InferenceFlags.AnyDefault ? anyType : emptyObjectType;
}
inferredType = context.flags & InferenceFlags.AnyDefault ? anyType : emptyObjectType;
}
inferenceSucceeded = true;
}
inference.inferredType = inferredType;
// Only do the constraint check if inference succeeded (to prevent cascading errors)
if (inferenceSucceeded) {
const constraint = getConstraintOfTypeParameter(context.signature.typeParameters[index]);
if (constraint) {
const instantiatedConstraint = instantiateType(constraint, context);
if (!isTypeAssignableTo(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
inference.inferredType = inferredType = instantiatedConstraint;
}
const constraint = getConstraintOfTypeParameter(context.signature.typeParameters[index]);
if (constraint) {
const instantiatedConstraint = instantiateType(constraint, context);
if (!isTypeAssignableTo(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
inference.inferredType = inferredType = instantiatedConstraint;
}
}
else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) {
// If inference failed, it is necessary to record the index of the failed type parameter (the one we are on).
// It might be that inference has already failed on a later type parameter on a previous call to inferTypeArguments.
// So if this failure is on preceding type parameter, this type parameter is the new failure index.
context.failedTypeParameterIndex = index;
}
}
return inferredType;
}
@@ -15005,17 +14939,6 @@ namespace ts {
}
}
// On this call to inferTypeArguments, we may get more inferences for certain type parameters that were not
// fixed last time. This means that a type parameter that failed inference last time may succeed this time,
// or vice versa. Therefore, the failedTypeParameterIndex is useless if it points to an unfixed type parameter,
// because it may change. So here we reset it. However, getInferredType will not revisit any type parameters
// that were previously fixed. So if a fixed type parameter failed previously, it will fail again because
// it will contain the exact same set of inferences. So if we reset the index from a fixed type parameter,
// we will lose information that we won't recover this time around.
if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) {
context.failedTypeParameterIndex = undefined;
}
// If a contextual type is available, infer from that type to the return type of the call expression. For
// example, given a 'function wrap<T, U>(cb: (x: T) => U): (x: T) => U' and a call expression
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
@@ -15584,9 +15507,9 @@ namespace ts {
// was fine. So if there is any overload that is only incorrect because of an
// argument, we will report an error on that one.
//
// function foo(s: string) {}
// function foo(n: number) {} // Report argument error on this overload
// function foo() {}
// function foo(s: string): void;
// function foo(n: number): void; // Report argument error on this overload
// function foo(): void;
// foo(true);
//
// If none of the overloads even made it that far, there are two possibilities.
@@ -15594,13 +15517,12 @@ namespace ts {
// report an error on that. Or none of the overloads even had correct arity,
// in which case give an arity error.
//
// function foo<T>(x: T, y: T) {} // Report type argument inference error
// function foo() {}
// foo(0, true);
// function foo<T extends string>(x: T): void; // Report type argument error
// function foo(): void;
// foo<number>(0);
//
let candidateForArgumentError: Signature;
let candidateForTypeArgumentError: Signature;
let resultOfFailedInference: InferenceContext;
let result: Signature;
// If we are in signature help, a trailing comma indicates that we intend to provide another argument,
@@ -15622,10 +15544,6 @@ namespace ts {
result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma);
}
if (!result) {
// Reinitialize these pointers for round two
candidateForArgumentError = undefined;
candidateForTypeArgumentError = undefined;
resultOfFailedInference = undefined;
result = chooseOverload(candidates, assignableRelation, signatureHelpTrailingComma);
}
if (result) {
@@ -15649,25 +15567,8 @@ namespace ts {
checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true);
}
else if (candidateForTypeArgumentError) {
if (!isTaggedTemplate && !isDecorator && typeArguments) {
const typeArguments = (<CallExpression>node).typeArguments;
checkTypeArguments(candidateForTypeArgumentError, typeArguments, map(typeArguments, getTypeFromTypeNode), /*reportErrors*/ true, fallbackError);
}
else {
Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0);
const failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex];
const inferenceCandidates = resultOfFailedInference.inferences[resultOfFailedInference.failedTypeParameterIndex].candidates;
let diagnosticChainHead = chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError
Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly,
typeToString(failedTypeParameter));
if (fallbackError) {
diagnosticChainHead = chainDiagnosticMessages(diagnosticChainHead, fallbackError);
}
reportNoCommonSupertypeError(inferenceCandidates, (<JsxOpeningLikeElement>node).tagName || (<CallExpression>node).expression || (<TaggedTemplateExpression>node).tag, diagnosticChainHead);
}
const typeArguments = (<CallExpression>node).typeArguments;
checkTypeArguments(candidateForTypeArgumentError, typeArguments, map(typeArguments, getTypeFromTypeNode), /*reportErrors*/ true, fallbackError);
}
else if (typeArguments && every(signatures, sig => length(sig.typeParameters) !== typeArguments.length)) {
let min = Number.POSITIVE_INFINITY;
@@ -15721,35 +15622,36 @@ namespace ts {
return resolveErrorCall(node);
function chooseOverload(candidates: Signature[], relation: Map<RelationComparisonResult>, signatureHelpTrailingComma = false) {
candidateForArgumentError = undefined;
candidateForTypeArgumentError = undefined;
for (const originalCandidate of candidates) {
if (!hasCorrectArity(node, args, originalCandidate, signatureHelpTrailingComma)) {
continue;
}
let candidate: Signature;
let typeArgumentsAreValid: boolean;
const inferenceContext = originalCandidate.typeParameters
? createInferenceContext(originalCandidate, /*flags*/ isInJavaScriptFile(node) ? InferenceFlags.AnyDefault : 0)
: undefined;
const inferenceContext = originalCandidate.typeParameters ?
createInferenceContext(originalCandidate, /*flags*/ isInJavaScriptFile(node) ? InferenceFlags.AnyDefault : 0) :
undefined;
while (true) {
candidate = originalCandidate;
if (candidate.typeParameters) {
let typeArgumentTypes: Type[] | undefined;
let typeArgumentTypes: Type[];
if (typeArguments) {
typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters));
typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false);
if (!checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)) {
candidateForTypeArgumentError = originalCandidate;
break;
}
}
else {
typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext);
typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined;
}
if (!typeArgumentsAreValid) {
break;
}
candidate = getSignatureInstantiation(candidate, typeArgumentTypes);
}
if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) {
candidateForArgumentError = candidate;
break;
}
const index = excludeArgument ? indexOf(excludeArgument, /*value*/ true) : -1;
@@ -15758,28 +15660,6 @@ namespace ts {
}
excludeArgument[index] = false;
}
// A post-mortem of this iteration of the loop. The signature was not applicable,
// so we want to track it as a candidate for reporting an error. If the candidate
// had no type parameters, or had no issues related to type arguments, we can
// report an error based on the arguments. If there was an issue with type
// arguments, then we can only report an error based on the type arguments.
if (originalCandidate.typeParameters) {
const instantiatedCandidate = candidate;
if (typeArgumentsAreValid) {
candidateForArgumentError = instantiatedCandidate;
}
else {
candidateForTypeArgumentError = originalCandidate;
if (!typeArguments) {
resultOfFailedInference = inferenceContext;
}
}
}
else {
Debug.assert(originalCandidate === candidate);
candidateForArgumentError = originalCandidate;
}
}
return undefined;
-2
View File
@@ -3406,8 +3406,6 @@ namespace ts {
signature: Signature; // Generic signature for which inferences are made
inferences: InferenceInfo[]; // Inferences made for each type parameter
flags: InferenceFlags; // Inference flags
failedTypeParameterIndex?: number; // Index of type parameter for which inference failed
// It is optional because in contextual signature instantiation, nothing fails
}
/* @internal */
@@ -1,6 +1,7 @@
tests/cases/conformance/decorators/decoratorCallGeneric.ts(7,2): error TS1238: Unable to resolve signature of class decorator when called as an expression.
The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'C' is not a valid type argument because it is not a supertype of candidate 'void'.
tests/cases/conformance/decorators/decoratorCallGeneric.ts(7,2): error TS2345: Argument of type 'typeof C' is not assignable to parameter of type 'I<C>'.
Types of property 'm' are incompatible.
Type '() => void' is not assignable to type '() => C'.
Type 'void' is not assignable to type 'C'.
==== tests/cases/conformance/decorators/decoratorCallGeneric.ts (1 errors) ====
@@ -12,9 +13,10 @@ tests/cases/conformance/decorators/decoratorCallGeneric.ts(7,2): error TS1238: U
@dec
~~~
!!! error TS1238: Unable to resolve signature of class decorator when called as an expression.
!!! error TS1238: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS1238: Type argument candidate 'C' is not a valid type argument because it is not a supertype of candidate 'void'.
!!! error TS2345: Argument of type 'typeof C' is not assignable to parameter of type 'I<C>'.
!!! error TS2345: Types of property 'm' are incompatible.
!!! error TS2345: Type '() => void' is not assignable to type '() => C'.
!!! error TS2345: Type 'void' is not assignable to type 'C'.
class C {
_brand: any;
static m() {}
@@ -1,7 +1,6 @@
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(2,6): error TS2339: Property 'length' does not exist on type '{}'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(5,6): error TS2339: Property 'length' does not exist on type 'Object'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(8,14): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(8,24): error TS2345: Argument of type '""' is not assignable to parameter of type '1'.
==== tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts (3 errors) ====
@@ -17,9 +16,8 @@ tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(8,14): error TS2453: The
function concat<T>(x: T, y: T): T { return null; }
var result = concat(1, ""); // error
~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
~~
!!! error TS2345: Argument of type '""' is not assignable to parameter of type '1'.
var elementCount = result.length;
function concat2<T, U>(x: T, y: U) { return null; }
@@ -1,10 +1,8 @@
tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts(2,1): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts(2,8): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
==== tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts (1 errors) ====
function bar<T>(item1: T, item2: T) { }
bar(1, ""); // Should be ok
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
~~
!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
+21 -5
View File
@@ -1,12 +1,28 @@
tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,15): error TS2453: The type argument for type parameter 'V' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'boolean' is not a valid type argument because it is not a supertype of candidate 'number'.
tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,19): error TS2345: Argument of type '([string, true] | [string, 0])[]' is not assignable to parameter of type 'Iterable<[string, boolean]>'.
Types of property '[Symbol.iterator]' are incompatible.
Type '() => IterableIterator<[string, true] | [string, 0]>' is not assignable to type '() => Iterator<[string, boolean]>'.
Type 'IterableIterator<[string, true] | [string, 0]>' is not assignable to type 'Iterator<[string, boolean]>'.
Types of property 'next' are incompatible.
Type '(value?: any) => IteratorResult<[string, true] | [string, 0]>' is not assignable to type '(value?: any) => IteratorResult<[string, boolean]>'.
Type 'IteratorResult<[string, true] | [string, 0]>' is not assignable to type 'IteratorResult<[string, boolean]>'.
Type '[string, true] | [string, 0]' is not assignable to type '[string, boolean]'.
Type '[string, 0]' is not assignable to type '[string, boolean]'.
Type '0' is not assignable to type 'boolean'.
==== tests/cases/conformance/es6/for-ofStatements/for-of39.ts (1 errors) ====
var map = new Map([["", true], ["", 0]]);
~~~
!!! error TS2453: The type argument for type parameter 'V' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'boolean' is not a valid type argument because it is not a supertype of candidate 'number'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '([string, true] | [string, 0])[]' is not assignable to parameter of type 'Iterable<[string, boolean]>'.
!!! error TS2345: Types of property '[Symbol.iterator]' are incompatible.
!!! error TS2345: Type '() => IterableIterator<[string, true] | [string, 0]>' is not assignable to type '() => Iterator<[string, boolean]>'.
!!! error TS2345: Type 'IterableIterator<[string, true] | [string, 0]>' is not assignable to type 'Iterator<[string, boolean]>'.
!!! error TS2345: Types of property 'next' are incompatible.
!!! error TS2345: Type '(value?: any) => IteratorResult<[string, true] | [string, 0]>' is not assignable to type '(value?: any) => IteratorResult<[string, boolean]>'.
!!! error TS2345: Type 'IteratorResult<[string, true] | [string, 0]>' is not assignable to type 'IteratorResult<[string, boolean]>'.
!!! error TS2345: Type '[string, true] | [string, 0]' is not assignable to type '[string, boolean]'.
!!! error TS2345: Type '[string, 0]' is not assignable to type '[string, boolean]'.
!!! error TS2345: Type '0' is not assignable to type 'boolean'.
for (var [k, v] of map) {
k;
v;
@@ -3,8 +3,9 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): err
Type 'State | 1' is not assignable to type 'StrategicState'.
Type '1' has no properties in common with type 'StrategicState'.
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(29,70): error TS7025: Generator implicitly has type 'IterableIterator<any>' because it does not yield any values. Consider supplying a return type.
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(32,42): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'State' is not a valid type argument because it is not a supertype of candidate '1'.
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(32,62): error TS2345: Argument of type '(state: State) => IterableIterator<1>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
Type 'IterableIterator<1>' is not assignable to type 'IterableIterator<State>'.
Type '1' is not assignable to type 'State'.
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,62): error TS2345: Argument of type '(state: State) => IterableIterator<State | 1>' is not assignable to parameter of type '(a: StrategicState) => IterableIterator<StrategicState>'.
Type 'IterableIterator<State | 1>' is not assignable to type 'IterableIterator<StrategicState>'.
@@ -49,9 +50,10 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,62): err
});
export const Nothing2: Strategy<State> = strategy("Nothing", function* (state: State) {
~~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'State' is not a valid type argument because it is not a supertype of candidate '1'.
~~~~~~~~
!!! error TS2345: Argument of type '(state: State) => IterableIterator<1>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
!!! error TS2345: Type 'IterableIterator<1>' is not assignable to type 'IterableIterator<State>'.
!!! error TS2345: Type '1' is not assignable to type 'State'.
return 1;
});
@@ -1,13 +1,16 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(26,10): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(30,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(33,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(34,16): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(35,15): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(26,18): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'.
Type 'string' is not assignable to type '1'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(30,23): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
Types of parameters 'x' and 'a' are incompatible.
Type '1' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(33,23): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
Types of parameters 'x' and 'a' are incompatible.
Type '1' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(34,24): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
Types of parameters 'x' and 'a' are incompatible.
Type '1' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(35,23): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'.
Type 'string' is not assignable to type '1'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts (5 errors) ====
@@ -37,28 +40,31 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun
var r7 = foo3(1, <Z>(a: Z) => '', ''); // string
var r8 = foo3(1, function (a) { return '' }, 1); // error
~~~~
!!! 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 '1' is not a valid type argument because it is not a supertype of candidate 'string'.
~~~~~~~~
!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'.
!!! error TS2345: Type 'string' is not assignable to type '1'.
var r9 = foo3<number, string>(1, (a) => '', ''); // string
function other<T, U>(t: T, u: U) {
var r10 = foo2(1, (x: T) => ''); // error
~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
!!! error TS2345: Types of parameters 'x' and 'a' are incompatible.
!!! error TS2345: Type '1' is not assignable to type 'T'.
var r10 = foo2(1, (x) => ''); // string
var r11 = foo3(1, (x: T) => '', ''); // error
~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
!!! error TS2345: Types of parameters 'x' and 'a' are incompatible.
!!! error TS2345: Type '1' is not assignable to type 'T'.
var r11b = foo3(1, (x: T) => '', 1); // error
~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
!!! error TS2345: Types of parameters 'x' and 'a' are incompatible.
!!! error TS2345: Type '1' is not assignable to type 'T'.
var r12 = foo3(1, function (a) { return '' }, 1); // error
~~~~
!!! 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 '1' is not a valid type argument because it is not a supertype of candidate 'string'.
~~~~~~~~
!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'.
!!! error TS2345: Type 'string' is not assignable to type '1'.
}
@@ -1,7 +1,9 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(29,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(40,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(29,18): error TS2345: Argument of type 'I2<string>' is not assignable to parameter of type 'new (a: 1) => string'.
Types of parameters 'x' and 'a' are incompatible.
Type '1' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(40,18): error TS2345: Argument of type 'I2<string>' is not assignable to parameter of type 'new (a: 1) => string'.
Types of parameters 'x' and 'a' are incompatible.
Type '1' is not assignable to type 'string'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts (2 errors) ====
@@ -34,9 +36,10 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun
}
var r4 = foo2(1, i2); // error
~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'.
~~
!!! error TS2345: Argument of type 'I2<string>' is not assignable to parameter of type 'new (a: 1) => string'.
!!! error TS2345: Types of parameters 'x' and 'a' are incompatible.
!!! error TS2345: Type '1' is not assignable to type 'string'.
var r4b = foo2(1, a); // any
var r5 = foo2(1, i); // any
var r6 = foo2<string, string>('', i2); // string
@@ -48,7 +51,8 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun
var r7 = foo3(null, i, ''); // any
var r7b = foo3(null, a, ''); // any
var r8 = foo3(1, i2, 1); // error
~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'.
~~
!!! error TS2345: Argument of type 'I2<string>' is not assignable to parameter of type 'new (a: 1) => string'.
!!! error TS2345: Types of parameters 'x' and 'a' are incompatible.
!!! error TS2345: Type '1' is not assignable to type 'string'.
var r9 = foo3<string, string>('', i2, ''); // string
@@ -1,59 +0,0 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments.ts(18,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '{ x: number; y?: number; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; z?: number; }'.
Property 'y' is missing in type '{ x: number; z?: number; }'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments.ts(19,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '{ x: number; z?: number; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y?: number; }'.
Property 'z' is missing in type '{ x: number; y?: number; }'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments.ts (2 errors) ====
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
function foo<T>(a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
//var r1 = foo((x: number) => 1, (x: string) => ''); // error
var r1b = foo((x) => 1, (x) => ''); // {} => {}
var r2 = foo((x: Object) => null, (x: string) => ''); // Object => Object
var r3 = foo((x: number) => 1, (x: Object) => null); // number => number
var r3ii = foo((x: number) => 1, (x: number) => 1); // number => number
var a: { x: number; y?: number; };
var b: { x: number; z?: number; };
var r4 = foo((x: typeof a) => a, (x: typeof b) => b); // typeof a => typeof a
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '{ x: number; y?: number; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; z?: number; }'.
!!! error TS2453: Property 'y' is missing in type '{ x: number; z?: number; }'.
var r5 = foo((x: typeof b) => b, (x: typeof a) => a); // typeof b => typeof b
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '{ x: number; z?: number; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y?: number; }'.
!!! error TS2453: Property 'z' is missing in type '{ x: number; y?: number; }'.
function other<T>(x: T) {
var r6 = foo((a: T) => a, (b: T) => b); // T => T
var r6b = foo((a) => a, (b) => b); // {} => {}
}
function other2<T extends Date>(x: T) {
var r7 = foo((a: T) => a, (b: T) => b); // T => T
var r7b = foo((a) => a, (b) => b); // {} => {}
var r8 = r7(null);
// BUG 835518
//var r9 = r7(new Date());
}
function foo2<T extends Date>(a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
function other3<T extends RegExp>(x: T) {
var r8 = foo2((a: Date) => a, (b: Date) => b); // Date => Date
}
@@ -0,0 +1,182 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments.ts ===
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
function foo<T>(a: (x: T) => T, b: (x: T) => T) {
>foo : Symbol(foo, Decl(genericCallWithGenericSignatureArguments.ts, 0, 0))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 3, 13))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 3, 16))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 3, 20))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 3, 13))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 3, 13))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 3, 31))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 3, 36))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 3, 13))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 3, 13))
var r: (x: T) => T;
>r : Symbol(r, Decl(genericCallWithGenericSignatureArguments.ts, 4, 7))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 4, 12))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 3, 13))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 3, 13))
return r;
>r : Symbol(r, Decl(genericCallWithGenericSignatureArguments.ts, 4, 7))
}
//var r1 = foo((x: number) => 1, (x: string) => ''); // error
var r1b = foo((x) => 1, (x) => ''); // {} => {}
>r1b : Symbol(r1b, Decl(genericCallWithGenericSignatureArguments.ts, 9, 3))
>foo : Symbol(foo, Decl(genericCallWithGenericSignatureArguments.ts, 0, 0))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 9, 15))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 9, 25))
var r2 = foo((x: Object) => null, (x: string) => ''); // Object => Object
>r2 : Symbol(r2, Decl(genericCallWithGenericSignatureArguments.ts, 10, 3))
>foo : Symbol(foo, Decl(genericCallWithGenericSignatureArguments.ts, 0, 0))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 10, 14))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 10, 35))
var r3 = foo((x: number) => 1, (x: Object) => null); // number => number
>r3 : Symbol(r3, Decl(genericCallWithGenericSignatureArguments.ts, 11, 3))
>foo : Symbol(foo, Decl(genericCallWithGenericSignatureArguments.ts, 0, 0))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 11, 14))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 11, 32))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var r3ii = foo((x: number) => 1, (x: number) => 1); // number => number
>r3ii : Symbol(r3ii, Decl(genericCallWithGenericSignatureArguments.ts, 12, 3))
>foo : Symbol(foo, Decl(genericCallWithGenericSignatureArguments.ts, 0, 0))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 12, 16))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 12, 34))
var a: { x: number; y?: number; };
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 14, 3))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 14, 8))
>y : Symbol(y, Decl(genericCallWithGenericSignatureArguments.ts, 14, 19))
var b: { x: number; z?: number; };
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 15, 3))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 15, 8))
>z : Symbol(z, Decl(genericCallWithGenericSignatureArguments.ts, 15, 19))
var r4 = foo((x: typeof a) => a, (x: typeof b) => b); // typeof a => typeof a
>r4 : Symbol(r4, Decl(genericCallWithGenericSignatureArguments.ts, 17, 3))
>foo : Symbol(foo, Decl(genericCallWithGenericSignatureArguments.ts, 0, 0))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 17, 14))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 14, 3))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 14, 3))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 17, 34))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 15, 3))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 15, 3))
var r5 = foo((x: typeof b) => b, (x: typeof a) => a); // typeof b => typeof b
>r5 : Symbol(r5, Decl(genericCallWithGenericSignatureArguments.ts, 18, 3))
>foo : Symbol(foo, Decl(genericCallWithGenericSignatureArguments.ts, 0, 0))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 18, 14))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 15, 3))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 15, 3))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 18, 34))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 14, 3))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 14, 3))
function other<T>(x: T) {
>other : Symbol(other, Decl(genericCallWithGenericSignatureArguments.ts, 18, 53))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 20, 15))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 20, 18))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 20, 15))
var r6 = foo((a: T) => a, (b: T) => b); // T => T
>r6 : Symbol(r6, Decl(genericCallWithGenericSignatureArguments.ts, 21, 7))
>foo : Symbol(foo, Decl(genericCallWithGenericSignatureArguments.ts, 0, 0))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 21, 18))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 20, 15))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 21, 18))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 21, 31))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 20, 15))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 21, 31))
var r6b = foo((a) => a, (b) => b); // {} => {}
>r6b : Symbol(r6b, Decl(genericCallWithGenericSignatureArguments.ts, 22, 7))
>foo : Symbol(foo, Decl(genericCallWithGenericSignatureArguments.ts, 0, 0))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 22, 19))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 22, 19))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 22, 29))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 22, 29))
}
function other2<T extends Date>(x: T) {
>other2 : Symbol(other2, Decl(genericCallWithGenericSignatureArguments.ts, 23, 1))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 25, 16))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 25, 32))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 25, 16))
var r7 = foo((a: T) => a, (b: T) => b); // T => T
>r7 : Symbol(r7, Decl(genericCallWithGenericSignatureArguments.ts, 26, 7))
>foo : Symbol(foo, Decl(genericCallWithGenericSignatureArguments.ts, 0, 0))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 26, 18))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 25, 16))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 26, 18))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 26, 31))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 25, 16))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 26, 31))
var r7b = foo((a) => a, (b) => b); // {} => {}
>r7b : Symbol(r7b, Decl(genericCallWithGenericSignatureArguments.ts, 27, 7))
>foo : Symbol(foo, Decl(genericCallWithGenericSignatureArguments.ts, 0, 0))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 27, 19))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 27, 19))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 27, 29))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 27, 29))
var r8 = r7(null);
>r8 : Symbol(r8, Decl(genericCallWithGenericSignatureArguments.ts, 28, 7))
>r7 : Symbol(r7, Decl(genericCallWithGenericSignatureArguments.ts, 26, 7))
// BUG 835518
//var r9 = r7(new Date());
}
function foo2<T extends Date>(a: (x: T) => T, b: (x: T) => T) {
>foo2 : Symbol(foo2, Decl(genericCallWithGenericSignatureArguments.ts, 31, 1))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 34, 14))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 34, 30))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 34, 34))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 34, 14))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 34, 14))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 34, 45))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 34, 50))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 34, 14))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 34, 14))
var r: (x: T) => T;
>r : Symbol(r, Decl(genericCallWithGenericSignatureArguments.ts, 35, 7))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 35, 12))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 34, 14))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 34, 14))
return r;
>r : Symbol(r, Decl(genericCallWithGenericSignatureArguments.ts, 35, 7))
}
function other3<T extends RegExp>(x: T) {
>other3 : Symbol(other3, Decl(genericCallWithGenericSignatureArguments.ts, 37, 1))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 39, 16))
>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(genericCallWithGenericSignatureArguments.ts, 39, 34))
>T : Symbol(T, Decl(genericCallWithGenericSignatureArguments.ts, 39, 16))
var r8 = foo2((a: Date) => a, (b: Date) => b); // Date => Date
>r8 : Symbol(r8, Decl(genericCallWithGenericSignatureArguments.ts, 40, 7))
>foo2 : Symbol(foo2, Decl(genericCallWithGenericSignatureArguments.ts, 31, 1))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 40, 19))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(genericCallWithGenericSignatureArguments.ts, 40, 19))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 40, 35))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>b : Symbol(b, Decl(genericCallWithGenericSignatureArguments.ts, 40, 35))
}
@@ -0,0 +1,225 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments.ts ===
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
function foo<T>(a: (x: T) => T, b: (x: T) => T) {
>foo : <T>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>T : T
>a : (x: T) => T
>x : T
>T : T
>T : T
>b : (x: T) => T
>x : T
>T : T
>T : T
var r: (x: T) => T;
>r : (x: T) => T
>x : T
>T : T
>T : T
return r;
>r : (x: T) => T
}
//var r1 = foo((x: number) => 1, (x: string) => ''); // error
var r1b = foo((x) => 1, (x) => ''); // {} => {}
>r1b : (x: {}) => {}
>foo((x) => 1, (x) => '') : (x: {}) => {}
>foo : <T>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x) => 1 : (x: {}) => number
>x : {}
>1 : 1
>(x) => '' : (x: {}) => string
>x : {}
>'' : ""
var r2 = foo((x: Object) => null, (x: string) => ''); // Object => Object
>r2 : (x: any) => any
>foo((x: Object) => null, (x: string) => '') : (x: any) => any
>foo : <T>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x: Object) => null : (x: Object) => any
>x : Object
>Object : Object
>null : null
>(x: string) => '' : (x: string) => string
>x : string
>'' : ""
var r3 = foo((x: number) => 1, (x: Object) => null); // number => number
>r3 : (x: any) => any
>foo((x: number) => 1, (x: Object) => null) : (x: any) => any
>foo : <T>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x: number) => 1 : (x: number) => number
>x : number
>1 : 1
>(x: Object) => null : (x: Object) => any
>x : Object
>Object : Object
>null : null
var r3ii = foo((x: number) => 1, (x: number) => 1); // number => number
>r3ii : (x: number) => number
>foo((x: number) => 1, (x: number) => 1) : (x: number) => number
>foo : <T>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x: number) => 1 : (x: number) => number
>x : number
>1 : 1
>(x: number) => 1 : (x: number) => number
>x : number
>1 : 1
var a: { x: number; y?: number; };
>a : { x: number; y?: number; }
>x : number
>y : number
var b: { x: number; z?: number; };
>b : { x: number; z?: number; }
>x : number
>z : number
var r4 = foo((x: typeof a) => a, (x: typeof b) => b); // typeof a => typeof a
>r4 : (x: { x: number; y?: number; }) => { x: number; y?: number; }
>foo((x: typeof a) => a, (x: typeof b) => b) : (x: { x: number; y?: number; }) => { x: number; y?: number; }
>foo : <T>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x: typeof a) => a : (x: { x: number; y?: number; }) => { x: number; y?: number; }
>x : { x: number; y?: number; }
>a : { x: number; y?: number; }
>a : { x: number; y?: number; }
>(x: typeof b) => b : (x: { x: number; z?: number; }) => { x: number; z?: number; }
>x : { x: number; z?: number; }
>b : { x: number; z?: number; }
>b : { x: number; z?: number; }
var r5 = foo((x: typeof b) => b, (x: typeof a) => a); // typeof b => typeof b
>r5 : (x: { x: number; z?: number; }) => { x: number; z?: number; }
>foo((x: typeof b) => b, (x: typeof a) => a) : (x: { x: number; z?: number; }) => { x: number; z?: number; }
>foo : <T>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x: typeof b) => b : (x: { x: number; z?: number; }) => { x: number; z?: number; }
>x : { x: number; z?: number; }
>b : { x: number; z?: number; }
>b : { x: number; z?: number; }
>(x: typeof a) => a : (x: { x: number; y?: number; }) => { x: number; y?: number; }
>x : { x: number; y?: number; }
>a : { x: number; y?: number; }
>a : { x: number; y?: number; }
function other<T>(x: T) {
>other : <T>(x: T) => void
>T : T
>x : T
>T : T
var r6 = foo((a: T) => a, (b: T) => b); // T => T
>r6 : (x: T) => T
>foo((a: T) => a, (b: T) => b) : (x: T) => T
>foo : <T>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(a: T) => a : (a: T) => T
>a : T
>T : T
>a : T
>(b: T) => b : (b: T) => T
>b : T
>T : T
>b : T
var r6b = foo((a) => a, (b) => b); // {} => {}
>r6b : (x: {}) => {}
>foo((a) => a, (b) => b) : (x: {}) => {}
>foo : <T>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(a) => a : (a: {}) => {}
>a : {}
>a : {}
>(b) => b : (b: {}) => {}
>b : {}
>b : {}
}
function other2<T extends Date>(x: T) {
>other2 : <T extends Date>(x: T) => void
>T : T
>Date : Date
>x : T
>T : T
var r7 = foo((a: T) => a, (b: T) => b); // T => T
>r7 : (x: T) => T
>foo((a: T) => a, (b: T) => b) : (x: T) => T
>foo : <T>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(a: T) => a : (a: T) => T
>a : T
>T : T
>a : T
>(b: T) => b : (b: T) => T
>b : T
>T : T
>b : T
var r7b = foo((a) => a, (b) => b); // {} => {}
>r7b : (x: {}) => {}
>foo((a) => a, (b) => b) : (x: {}) => {}
>foo : <T>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(a) => a : (a: {}) => {}
>a : {}
>a : {}
>(b) => b : (b: {}) => {}
>b : {}
>b : {}
var r8 = r7(null);
>r8 : T
>r7(null) : T
>r7 : (x: T) => T
>null : null
// BUG 835518
//var r9 = r7(new Date());
}
function foo2<T extends Date>(a: (x: T) => T, b: (x: T) => T) {
>foo2 : <T extends Date>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>T : T
>Date : Date
>a : (x: T) => T
>x : T
>T : T
>T : T
>b : (x: T) => T
>x : T
>T : T
>T : T
var r: (x: T) => T;
>r : (x: T) => T
>x : T
>T : T
>T : T
return r;
>r : (x: T) => T
}
function other3<T extends RegExp>(x: T) {
>other3 : <T extends RegExp>(x: T) => void
>T : T
>RegExp : RegExp
>x : T
>T : T
var r8 = foo2((a: Date) => a, (b: Date) => b); // Date => Date
>r8 : (x: Date) => Date
>foo2((a: Date) => a, (b: Date) => b) : (x: Date) => Date
>foo2 : <T extends Date>(a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(a: Date) => a : (a: Date) => Date
>a : Date
>Date : Date
>a : Date
>(b: Date) => b : (b: Date) => Date
>b : Date
>Date : Date
>b : Date
}
@@ -1,5 +1,6 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(10,29): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(10,51): error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => number'.
Types of parameters 'x' and 'x' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(15,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(16,22): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(25,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'.
@@ -27,9 +28,10 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen
}
var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => '');
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => number'.
!!! error TS2345: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
function other2<T extends Date>(x: T) {
var r7 = foo((a: T) => a, (b: T) => b); // T => T
@@ -1,8 +1,8 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts(32,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '(y: string) => string' is not a valid type argument because it is not a supertype of candidate '(a: string) => boolean'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts(32,19): error TS2345: Argument of type '(a1: (y: string) => string) => (n: Object) => number' is not assignable to parameter of type '(x: (a: string) => boolean) => (n: Object) => number'.
Types of parameters 'a1' and 'x' are incompatible.
Type 'boolean' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts(33,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '(n: Object) => number' is not a valid type argument because it is not a supertype of candidate 'number'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts(33,69): error TS2345: Argument of type '(a2: (z: string) => boolean) => number' is not assignable to parameter of type '(x: (z: string) => boolean) => (n: Object) => number'.
Type 'number' is not assignable to type '(n: Object) => number'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts (2 errors) ====
@@ -38,11 +38,11 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen
var x: (a: string) => boolean;
var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // error
~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '(y: string) => string' is not a valid type argument because it is not a supertype of candidate '(a: string) => boolean'.
!!! error TS2453: Type 'boolean' is not assignable to type 'string'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(a1: (y: string) => string) => (n: Object) => number' is not assignable to parameter of type '(x: (a: string) => boolean) => (n: Object) => number'.
!!! error TS2345: Types of parameters 'a1' and 'x' are incompatible.
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // error
~~~~
!!! 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 '(n: Object) => number' is not a valid type argument because it is not a supertype of candidate 'number'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(a2: (z: string) => boolean) => number' is not assignable to parameter of type '(x: (z: string) => boolean) => (n: Object) => number'.
!!! error TS2345: Type 'number' is not assignable to type '(n: Object) => number'.
@@ -1,48 +0,0 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts(12,9): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '{ x: number; y?: number; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; z?: number; }'.
Property 'y' is missing in type '{ x: number; z?: number; }'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts(13,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '{ x: number; z?: number; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y?: number; }'.
Property 'z' is missing in type '{ x: number; y?: number; }'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts (2 errors) ====
// generic type argument inference where inference leads to two candidates that are both supertypes of all candidates
// we choose the first candidate so the result is dependent on the order of the arguments provided
function foo<T>(x: T, y: T) {
var r: T;
return r;
}
var a: { x: number; y?: number; };
var b: { x: number; z?: number; };
var r = foo(a, b); // { x: number; y?: number; };
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '{ x: number; y?: number; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; z?: number; }'.
!!! error TS2453: Property 'y' is missing in type '{ x: number; z?: number; }'.
var r2 = foo(b, a); // { x: number; z?: number; };
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '{ x: number; z?: number; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y?: number; }'.
!!! error TS2453: Property 'z' is missing in type '{ x: number; y?: number; }'.
var x: { x: number; };
var y: { x?: number; };
var r3 = foo(a, x); // { x: number; y?: number; };
var r4 = foo(x, a); // { x: number; };
var r5 = foo(a, y); // { x?: number; };
var r5 = foo(y, a); // { x?: number; };
var r6 = foo(x, y); // { x?: number; };
var r6 = foo(y, x); // { x?: number; };
var s1: (x: Object) => string;
var s2: (x: string) => string;
var r7 = foo(s1, s2); // (x: Object) => string;
var r8 = foo(s2, s1); // (x: string) => string;
@@ -0,0 +1,107 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts ===
// generic type argument inference where inference leads to two candidates that are both supertypes of all candidates
// we choose the first candidate so the result is dependent on the order of the arguments provided
function foo<T>(x: T, y: T) {
>foo : Symbol(foo, Decl(genericCallWithNonSymmetricSubtypes.ts, 0, 0))
>T : Symbol(T, Decl(genericCallWithNonSymmetricSubtypes.ts, 3, 13))
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 3, 16))
>T : Symbol(T, Decl(genericCallWithNonSymmetricSubtypes.ts, 3, 13))
>y : Symbol(y, Decl(genericCallWithNonSymmetricSubtypes.ts, 3, 21))
>T : Symbol(T, Decl(genericCallWithNonSymmetricSubtypes.ts, 3, 13))
var r: T;
>r : Symbol(r, Decl(genericCallWithNonSymmetricSubtypes.ts, 4, 7))
>T : Symbol(T, Decl(genericCallWithNonSymmetricSubtypes.ts, 3, 13))
return r;
>r : Symbol(r, Decl(genericCallWithNonSymmetricSubtypes.ts, 4, 7))
}
var a: { x: number; y?: number; };
>a : Symbol(a, Decl(genericCallWithNonSymmetricSubtypes.ts, 8, 3))
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 8, 8))
>y : Symbol(y, Decl(genericCallWithNonSymmetricSubtypes.ts, 8, 19))
var b: { x: number; z?: number; };
>b : Symbol(b, Decl(genericCallWithNonSymmetricSubtypes.ts, 9, 3))
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 9, 8))
>z : Symbol(z, Decl(genericCallWithNonSymmetricSubtypes.ts, 9, 19))
var r = foo(a, b); // { x: number; y?: number; };
>r : Symbol(r, Decl(genericCallWithNonSymmetricSubtypes.ts, 11, 3))
>foo : Symbol(foo, Decl(genericCallWithNonSymmetricSubtypes.ts, 0, 0))
>a : Symbol(a, Decl(genericCallWithNonSymmetricSubtypes.ts, 8, 3))
>b : Symbol(b, Decl(genericCallWithNonSymmetricSubtypes.ts, 9, 3))
var r2 = foo(b, a); // { x: number; z?: number; };
>r2 : Symbol(r2, Decl(genericCallWithNonSymmetricSubtypes.ts, 12, 3))
>foo : Symbol(foo, Decl(genericCallWithNonSymmetricSubtypes.ts, 0, 0))
>b : Symbol(b, Decl(genericCallWithNonSymmetricSubtypes.ts, 9, 3))
>a : Symbol(a, Decl(genericCallWithNonSymmetricSubtypes.ts, 8, 3))
var x: { x: number; };
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 14, 3))
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 14, 8))
var y: { x?: number; };
>y : Symbol(y, Decl(genericCallWithNonSymmetricSubtypes.ts, 15, 3))
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 15, 8))
var r3 = foo(a, x); // { x: number; y?: number; };
>r3 : Symbol(r3, Decl(genericCallWithNonSymmetricSubtypes.ts, 17, 3))
>foo : Symbol(foo, Decl(genericCallWithNonSymmetricSubtypes.ts, 0, 0))
>a : Symbol(a, Decl(genericCallWithNonSymmetricSubtypes.ts, 8, 3))
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 14, 3))
var r4 = foo(x, a); // { x: number; };
>r4 : Symbol(r4, Decl(genericCallWithNonSymmetricSubtypes.ts, 18, 3))
>foo : Symbol(foo, Decl(genericCallWithNonSymmetricSubtypes.ts, 0, 0))
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 14, 3))
>a : Symbol(a, Decl(genericCallWithNonSymmetricSubtypes.ts, 8, 3))
var r5 = foo(a, y); // { x?: number; };
>r5 : Symbol(r5, Decl(genericCallWithNonSymmetricSubtypes.ts, 20, 3), Decl(genericCallWithNonSymmetricSubtypes.ts, 21, 3))
>foo : Symbol(foo, Decl(genericCallWithNonSymmetricSubtypes.ts, 0, 0))
>a : Symbol(a, Decl(genericCallWithNonSymmetricSubtypes.ts, 8, 3))
>y : Symbol(y, Decl(genericCallWithNonSymmetricSubtypes.ts, 15, 3))
var r5 = foo(y, a); // { x?: number; };
>r5 : Symbol(r5, Decl(genericCallWithNonSymmetricSubtypes.ts, 20, 3), Decl(genericCallWithNonSymmetricSubtypes.ts, 21, 3))
>foo : Symbol(foo, Decl(genericCallWithNonSymmetricSubtypes.ts, 0, 0))
>y : Symbol(y, Decl(genericCallWithNonSymmetricSubtypes.ts, 15, 3))
>a : Symbol(a, Decl(genericCallWithNonSymmetricSubtypes.ts, 8, 3))
var r6 = foo(x, y); // { x?: number; };
>r6 : Symbol(r6, Decl(genericCallWithNonSymmetricSubtypes.ts, 23, 3), Decl(genericCallWithNonSymmetricSubtypes.ts, 24, 3))
>foo : Symbol(foo, Decl(genericCallWithNonSymmetricSubtypes.ts, 0, 0))
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 14, 3))
>y : Symbol(y, Decl(genericCallWithNonSymmetricSubtypes.ts, 15, 3))
var r6 = foo(y, x); // { x?: number; };
>r6 : Symbol(r6, Decl(genericCallWithNonSymmetricSubtypes.ts, 23, 3), Decl(genericCallWithNonSymmetricSubtypes.ts, 24, 3))
>foo : Symbol(foo, Decl(genericCallWithNonSymmetricSubtypes.ts, 0, 0))
>y : Symbol(y, Decl(genericCallWithNonSymmetricSubtypes.ts, 15, 3))
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 14, 3))
var s1: (x: Object) => string;
>s1 : Symbol(s1, Decl(genericCallWithNonSymmetricSubtypes.ts, 26, 3))
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 26, 9))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var s2: (x: string) => string;
>s2 : Symbol(s2, Decl(genericCallWithNonSymmetricSubtypes.ts, 27, 3))
>x : Symbol(x, Decl(genericCallWithNonSymmetricSubtypes.ts, 27, 9))
var r7 = foo(s1, s2); // (x: Object) => string;
>r7 : Symbol(r7, Decl(genericCallWithNonSymmetricSubtypes.ts, 29, 3))
>foo : Symbol(foo, Decl(genericCallWithNonSymmetricSubtypes.ts, 0, 0))
>s1 : Symbol(s1, Decl(genericCallWithNonSymmetricSubtypes.ts, 26, 3))
>s2 : Symbol(s2, Decl(genericCallWithNonSymmetricSubtypes.ts, 27, 3))
var r8 = foo(s2, s1); // (x: string) => string;
>r8 : Symbol(r8, Decl(genericCallWithNonSymmetricSubtypes.ts, 30, 3))
>foo : Symbol(foo, Decl(genericCallWithNonSymmetricSubtypes.ts, 0, 0))
>s2 : Symbol(s2, Decl(genericCallWithNonSymmetricSubtypes.ts, 27, 3))
>s1 : Symbol(s1, Decl(genericCallWithNonSymmetricSubtypes.ts, 26, 3))
@@ -0,0 +1,117 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts ===
// generic type argument inference where inference leads to two candidates that are both supertypes of all candidates
// we choose the first candidate so the result is dependent on the order of the arguments provided
function foo<T>(x: T, y: T) {
>foo : <T>(x: T, y: T) => T
>T : T
>x : T
>T : T
>y : T
>T : T
var r: T;
>r : T
>T : T
return r;
>r : T
}
var a: { x: number; y?: number; };
>a : { x: number; y?: number; }
>x : number
>y : number
var b: { x: number; z?: number; };
>b : { x: number; z?: number; }
>x : number
>z : number
var r = foo(a, b); // { x: number; y?: number; };
>r : { x: number; y?: number; }
>foo(a, b) : { x: number; y?: number; }
>foo : <T>(x: T, y: T) => T
>a : { x: number; y?: number; }
>b : { x: number; z?: number; }
var r2 = foo(b, a); // { x: number; z?: number; };
>r2 : { x: number; z?: number; }
>foo(b, a) : { x: number; z?: number; }
>foo : <T>(x: T, y: T) => T
>b : { x: number; z?: number; }
>a : { x: number; y?: number; }
var x: { x: number; };
>x : { x: number; }
>x : number
var y: { x?: number; };
>y : { x?: number; }
>x : number
var r3 = foo(a, x); // { x: number; y?: number; };
>r3 : { x: number; }
>foo(a, x) : { x: number; }
>foo : <T>(x: T, y: T) => T
>a : { x: number; y?: number; }
>x : { x: number; }
var r4 = foo(x, a); // { x: number; };
>r4 : { x: number; }
>foo(x, a) : { x: number; }
>foo : <T>(x: T, y: T) => T
>x : { x: number; }
>a : { x: number; y?: number; }
var r5 = foo(a, y); // { x?: number; };
>r5 : { x?: number; }
>foo(a, y) : { x?: number; }
>foo : <T>(x: T, y: T) => T
>a : { x: number; y?: number; }
>y : { x?: number; }
var r5 = foo(y, a); // { x?: number; };
>r5 : { x?: number; }
>foo(y, a) : { x?: number; }
>foo : <T>(x: T, y: T) => T
>y : { x?: number; }
>a : { x: number; y?: number; }
var r6 = foo(x, y); // { x?: number; };
>r6 : { x?: number; }
>foo(x, y) : { x?: number; }
>foo : <T>(x: T, y: T) => T
>x : { x: number; }
>y : { x?: number; }
var r6 = foo(y, x); // { x?: number; };
>r6 : { x?: number; }
>foo(y, x) : { x?: number; }
>foo : <T>(x: T, y: T) => T
>y : { x?: number; }
>x : { x: number; }
var s1: (x: Object) => string;
>s1 : (x: Object) => string
>x : Object
>Object : Object
var s2: (x: string) => string;
>s2 : (x: string) => string
>x : string
var r7 = foo(s1, s2); // (x: Object) => string;
>r7 : (x: string) => string
>foo(s1, s2) : (x: string) => string
>foo : <T>(x: T, y: T) => T
>s1 : (x: Object) => string
>s2 : (x: string) => string
var r8 = foo(s2, s1); // (x: string) => string;
>r8 : (x: Object) => string
>foo(s2, s1) : (x: Object) => string
>foo : <T>(x: T, y: T) => T
>s2 : (x: string) => string
>s1 : (x: Object) => string
@@ -1,5 +1,6 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,9): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,13): error TS2345: Argument of type '{ bar: number; baz: string; }' is not assignable to parameter of type '{ bar: number; baz: number; }'.
Types of property 'baz' are incompatible.
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts (1 errors) ====
@@ -8,9 +9,10 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj
}
var r = foo({ bar: 1, baz: '' }); // error
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ bar: number; baz: string; }' is not assignable to parameter of type '{ bar: number; baz: number; }'.
!!! error TS2345: Types of property 'baz' are incompatible.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var r2 = foo({ bar: 1, baz: 1 }); // T = number
var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo
var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object
@@ -1,5 +1,6 @@
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(3,9): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(3,13): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'.
Types of property 'y' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(4,22): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'.
Types of property 'y' are incompatible.
Type 'string' is not assignable to type 'number'.
@@ -18,9 +19,10 @@ tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(7,22): error TS23
function foo<T>(n: { x: T; y: T }, m: T) { return m; }
// these are all errors
var x = foo({ x: 3, y: "" }, 4);
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'.
!!! error TS2345: Types of property 'y' are incompatible.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var x2 = foo<number>({ x: 3, y: "" }, 4);
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'.
@@ -1,5 +1,5 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts(20,9): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'C' is not a valid type argument because it is not a supertype of candidate 'D'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts(20,17): error TS2345: Argument of type 'X<D>' is not assignable to parameter of type 'X<C>'.
Type 'D' is not assignable to type 'C'.
Types have separate declarations of a private property 'x'.
@@ -24,8 +24,8 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj
var c1 = new X<C>();
var d1 = new X<D>();
var r = foo(c1, d1); // error
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'C' is not a valid type argument because it is not a supertype of candidate 'D'.
!!! error TS2453: Types have separate declarations of a private property 'x'.
~~
!!! error TS2345: Argument of type 'X<D>' is not assignable to parameter of type 'X<C>'.
!!! error TS2345: Type 'D' is not assignable to type 'C'.
!!! error TS2345: Types have separate declarations of a private property 'x'.
var r2 = foo(c1, c1); // ok
@@ -1,6 +1,7 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(18,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'Derived' is not a valid type argument because it is not a supertype of candidate 'Derived2'.
Property 'y' is missing in type 'Derived2'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(18,12): error TS2345: Argument of type '{ x: Derived; y: Derived2; }' is not assignable to parameter of type '{ x: Derived; y: Derived; }'.
Types of property 'y' are incompatible.
Type 'Derived2' is not assignable to type 'Derived'.
Property 'y' is missing in type 'Derived2'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts (1 errors) ====
@@ -22,10 +23,11 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj
}
var r1 = f({ x: new Derived(), y: new Derived2() }); // error because neither is supertype of the other
~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'Derived' is not a valid type argument because it is not a supertype of candidate 'Derived2'.
!!! error TS2453: Property 'y' is missing in type 'Derived2'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ x: Derived; y: Derived2; }' is not assignable to parameter of type '{ x: Derived; y: Derived; }'.
!!! error TS2345: Types of property 'y' are incompatible.
!!! error TS2345: Type 'Derived2' is not assignable to type 'Derived'.
!!! error TS2345: Property 'y' is missing in type 'Derived2'.
function f2<T extends Base, U extends { x: T; y: T }>(a: U) {
var r: T;
@@ -1,56 +0,0 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts(36,14): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'boolean' is not a valid type argument because it is not a supertype of candidate 'number'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts (1 errors) ====
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them
// Inferences are made quadratic-pairwise to and from these overload sets
module NonGenericParameter {
var a: {
new(x: boolean): boolean;
new(x: string): string;
}
function foo4(cb: typeof a) {
return new cb(null);
}
var r = foo4(a);
var b: { new <T>(x: T): T };
var r2 = foo4(b);
}
module GenericParameter {
function foo5<T>(cb: { new(x: T): string; new(x: number): T }) {
return cb;
}
var a: {
new (x: boolean): string;
new (x: number): boolean;
}
var r5 = foo5(a); // new{} => string; new(x:number) => {}
var b: { new<T>(x: T): string; new<T>(x: number): T; }
var r7 = foo5(b); // new any => string; new(x:number) => any
function foo6<T>(cb: { new(x: T): string; new(x: T, y?: T): string }) {
return cb;
}
var r8 = foo6(a); // error
~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'boolean' is not a valid type argument because it is not a supertype of candidate 'number'.
var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string
function foo7<T>(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) {
return cb;
}
var r13 = foo7(1, b); // new any => string; new(x:any, y?:any) => string
var c: { new <T>(x: T): string; <T>(x: number): T; }
var c2: { new <T>(x: T): string; new<T>(x: number): T; }
var r14 = foo7(1, c); // new any => string; new(x:any, y?:any) => string
var r15 = foo7(1, c2); // new any => string; new(x:any, y?:any) => string
}
@@ -0,0 +1,163 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts ===
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them
// Inferences are made quadratic-pairwise to and from these overload sets
module NonGenericParameter {
>NonGenericParameter : Symbol(NonGenericParameter, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 0, 0))
var a: {
>a : Symbol(a, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 4, 7))
new(x: boolean): boolean;
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 5, 12))
new(x: string): string;
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 6, 12))
}
function foo4(cb: typeof a) {
>foo4 : Symbol(foo4, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 7, 5))
>cb : Symbol(cb, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 9, 18))
>a : Symbol(a, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 4, 7))
return new cb(null);
>cb : Symbol(cb, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 9, 18))
}
var r = foo4(a);
>r : Symbol(r, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 13, 7))
>foo4 : Symbol(foo4, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 7, 5))
>a : Symbol(a, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 4, 7))
var b: { new <T>(x: T): T };
>b : Symbol(b, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 14, 7))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 14, 18))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 14, 21))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 14, 18))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 14, 18))
var r2 = foo4(b);
>r2 : Symbol(r2, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 15, 7))
>foo4 : Symbol(foo4, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 7, 5))
>b : Symbol(b, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 14, 7))
}
module GenericParameter {
>GenericParameter : Symbol(GenericParameter, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 16, 1))
function foo5<T>(cb: { new(x: T): string; new(x: number): T }) {
>foo5 : Symbol(foo5, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 18, 25))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 19, 18))
>cb : Symbol(cb, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 19, 21))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 19, 31))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 19, 18))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 19, 50))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 19, 18))
return cb;
>cb : Symbol(cb, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 19, 21))
}
var a: {
>a : Symbol(a, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 23, 7))
new (x: boolean): string;
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 24, 13))
new (x: number): boolean;
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 25, 13))
}
var r5 = foo5(a); // new{} => string; new(x:number) => {}
>r5 : Symbol(r5, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 27, 7))
>foo5 : Symbol(foo5, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 18, 25))
>a : Symbol(a, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 23, 7))
var b: { new<T>(x: T): string; new<T>(x: number): T; }
>b : Symbol(b, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 28, 7))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 28, 17))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 28, 20))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 28, 17))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 28, 39))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 28, 42))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 28, 39))
var r7 = foo5(b); // new any => string; new(x:number) => any
>r7 : Symbol(r7, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 29, 7))
>foo5 : Symbol(foo5, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 18, 25))
>b : Symbol(b, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 28, 7))
function foo6<T>(cb: { new(x: T): string; new(x: T, y?: T): string }) {
>foo6 : Symbol(foo6, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 29, 21))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 31, 18))
>cb : Symbol(cb, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 31, 21))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 31, 31))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 31, 18))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 31, 50))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 31, 18))
>y : Symbol(y, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 31, 55))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 31, 18))
return cb;
>cb : Symbol(cb, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 31, 21))
}
var r8 = foo6(a); // error
>r8 : Symbol(r8, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 35, 7))
>foo6 : Symbol(foo6, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 29, 21))
>a : Symbol(a, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 23, 7))
var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string
>r9 : Symbol(r9, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 36, 7))
>foo6 : Symbol(foo6, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 29, 21))
>b : Symbol(b, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 28, 7))
function foo7<T>(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) {
>foo7 : Symbol(foo7, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 36, 21))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 38, 18))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 38, 21))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 38, 18))
>cb : Symbol(cb, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 38, 25))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 38, 36))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 38, 18))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 38, 55))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 38, 18))
>y : Symbol(y, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 38, 60))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 38, 18))
return cb;
>cb : Symbol(cb, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 38, 25))
}
var r13 = foo7(1, b); // new any => string; new(x:any, y?:any) => string
>r13 : Symbol(r13, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 42, 7))
>foo7 : Symbol(foo7, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 36, 21))
>b : Symbol(b, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 28, 7))
var c: { new <T>(x: T): string; <T>(x: number): T; }
>c : Symbol(c, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 43, 7))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 43, 18))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 43, 21))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 43, 18))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 43, 37))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 43, 40))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 43, 37))
var c2: { new <T>(x: T): string; new<T>(x: number): T; }
>c2 : Symbol(c2, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 44, 7))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 44, 19))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 44, 22))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 44, 19))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 44, 41))
>x : Symbol(x, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 44, 44))
>T : Symbol(T, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 44, 41))
var r14 = foo7(1, c); // new any => string; new(x:any, y?:any) => string
>r14 : Symbol(r14, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 45, 7))
>foo7 : Symbol(foo7, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 36, 21))
>c : Symbol(c, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 43, 7))
var r15 = foo7(1, c2); // new any => string; new(x:any, y?:any) => string
>r15 : Symbol(r15, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 46, 7))
>foo7 : Symbol(foo7, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 36, 21))
>c2 : Symbol(c2, Decl(genericCallWithOverloadedConstructorTypedArguments.ts, 44, 7))
}
@@ -0,0 +1,177 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts ===
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them
// Inferences are made quadratic-pairwise to and from these overload sets
module NonGenericParameter {
>NonGenericParameter : typeof NonGenericParameter
var a: {
>a : { new (x: boolean): boolean; new (x: string): string; }
new(x: boolean): boolean;
>x : boolean
new(x: string): string;
>x : string
}
function foo4(cb: typeof a) {
>foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean
>cb : { new (x: boolean): boolean; new (x: string): string; }
>a : { new (x: boolean): boolean; new (x: string): string; }
return new cb(null);
>new cb(null) : boolean
>cb : { new (x: boolean): boolean; new (x: string): string; }
>null : null
}
var r = foo4(a);
>r : boolean
>foo4(a) : boolean
>foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean
>a : { new (x: boolean): boolean; new (x: string): string; }
var b: { new <T>(x: T): T };
>b : new <T>(x: T) => T
>T : T
>x : T
>T : T
>T : T
var r2 = foo4(b);
>r2 : boolean
>foo4(b) : boolean
>foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean
>b : new <T>(x: T) => T
}
module GenericParameter {
>GenericParameter : typeof GenericParameter
function foo5<T>(cb: { new(x: T): string; new(x: number): T }) {
>foo5 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
>T : T
>cb : { new (x: T): string; new (x: number): T; }
>x : T
>T : T
>x : number
>T : T
return cb;
>cb : { new (x: T): string; new (x: number): T; }
}
var a: {
>a : { new (x: boolean): string; new (x: number): boolean; }
new (x: boolean): string;
>x : boolean
new (x: number): boolean;
>x : number
}
var r5 = foo5(a); // new{} => string; new(x:number) => {}
>r5 : { new (x: boolean): string; new (x: number): boolean; }
>foo5(a) : { new (x: boolean): string; new (x: number): boolean; }
>foo5 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
>a : { new (x: boolean): string; new (x: number): boolean; }
var b: { new<T>(x: T): string; new<T>(x: number): T; }
>b : { new <T>(x: T): string; new <T>(x: number): T; }
>T : T
>x : T
>T : T
>T : T
>x : number
>T : T
var r7 = foo5(b); // new any => string; new(x:number) => any
>r7 : { new (x: any): string; new (x: number): any; }
>foo5(b) : { new (x: any): string; new (x: number): any; }
>foo5 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
>b : { new <T>(x: T): string; new <T>(x: number): T; }
function foo6<T>(cb: { new(x: T): string; new(x: T, y?: T): string }) {
>foo6 : <T>(cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>T : T
>cb : { new (x: T): string; new (x: T, y?: T): string; }
>x : T
>T : T
>x : T
>T : T
>y : T
>T : T
return cb;
>cb : { new (x: T): string; new (x: T, y?: T): string; }
}
var r8 = foo6(a); // error
>r8 : { new (x: boolean): string; new (x: boolean, y?: boolean): string; }
>foo6(a) : { new (x: boolean): string; new (x: boolean, y?: boolean): string; }
>foo6 : <T>(cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>a : { new (x: boolean): string; new (x: number): boolean; }
var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string
>r9 : { new (x: any): string; new (x: any, y?: any): string; }
>foo6(b) : { new (x: any): string; new (x: any, y?: any): string; }
>foo6 : <T>(cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>b : { new <T>(x: T): string; new <T>(x: number): T; }
function foo7<T>(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) {
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>T : T
>x : T
>T : T
>cb : { new (x: T): string; new (x: T, y?: T): string; }
>x : T
>T : T
>x : T
>T : T
>y : T
>T : T
return cb;
>cb : { new (x: T): string; new (x: T, y?: T): string; }
}
var r13 = foo7(1, b); // new any => string; new(x:any, y?:any) => string
>r13 : { new (x: any): string; new (x: any, y?: any): string; }
>foo7(1, b) : { new (x: any): string; new (x: any, y?: any): string; }
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>1 : 1
>b : { new <T>(x: T): string; new <T>(x: number): T; }
var c: { new <T>(x: T): string; <T>(x: number): T; }
>c : { <T>(x: number): T; new <T>(x: T): string; }
>T : T
>x : T
>T : T
>T : T
>x : number
>T : T
var c2: { new <T>(x: T): string; new<T>(x: number): T; }
>c2 : { new <T>(x: T): string; new <T>(x: number): T; }
>T : T
>x : T
>T : T
>T : T
>x : number
>T : T
var r14 = foo7(1, c); // new any => string; new(x:any, y?:any) => string
>r14 : { new (x: any): string; new (x: any, y?: any): string; }
>foo7(1, c) : { new (x: any): string; new (x: any, y?: any): string; }
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>1 : 1
>c : { <T>(x: number): T; new <T>(x: T): string; }
var r15 = foo7(1, c2); // new any => string; new(x:any, y?:any) => string
>r15 : { new (x: any): string; new (x: any, y?: any): string; }
>foo7(1, c2) : { new (x: any): string; new (x: any, y?: any): string; }
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>1 : 1
>c2 : { new <T>(x: T): string; new <T>(x: number): T; }
}
@@ -1,11 +1,14 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(57,19): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(60,19): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(61,20): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(62,19): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(57,29): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
Types of parameters 'x' and 'a' are incompatible.
Type '1' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(60,30): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
Types of parameters 'x' and 'a' are incompatible.
Type '1' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(61,31): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
Types of parameters 'x' and 'a' are incompatible.
Type '1' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(62,30): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'.
Type 'string' is not assignable to type '1'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts (4 errors) ====
@@ -66,22 +69,25 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFu
function other<T, U>(t: T, u: U) {
var r10 = c.foo2(1, (x: T) => ''); // error
~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
!!! error TS2345: Types of parameters 'x' and 'a' are incompatible.
!!! error TS2345: Type '1' is not assignable to type 'T'.
var r10 = c.foo2(1, (x) => ''); // string
var r11 = c3.foo3(1, (x: T) => '', ''); // error
~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
!!! error TS2345: Types of parameters 'x' and 'a' are incompatible.
!!! error TS2345: Type '1' is not assignable to type 'T'.
var r11b = c3.foo3(1, (x: T) => '', 1); // error
~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'.
!!! error TS2345: Types of parameters 'x' and 'a' are incompatible.
!!! error TS2345: Type '1' is not assignable to type 'T'.
var r12 = c3.foo3(1, function (a) { return '' }, 1); // error
~~~~~~~
!!! 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 '1' is not a valid type argument because it is not a supertype of candidate 'string'.
~~~~~~~~
!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'.
!!! error TS2345: Type 'string' is not assignable to type '1'.
}
}
@@ -1,17 +1,14 @@
tests/cases/compiler/genericRestArgs.ts(2,12): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
tests/cases/compiler/genericRestArgs.ts(2,26): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
tests/cases/compiler/genericRestArgs.ts(5,34): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
tests/cases/compiler/genericRestArgs.ts(10,12): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
tests/cases/compiler/genericRestArgs.ts(10,29): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type '1' is not assignable to parameter of type 'any[]'.
==== tests/cases/compiler/genericRestArgs.ts (4 errors) ====
function makeArrayG<T>(...items: T[]): T[] { return items; }
var a1Ga = makeArrayG(1, ""); // no error
~~~~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
~~
!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
var a1Gb = makeArrayG<any>(1, "");
var a1Gc = makeArrayG<Object>(1, "");
var a1Gd = makeArrayG<number>(1, ""); // error
@@ -22,9 +19,8 @@ tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type '
return [item1, item2, item3];
}
var a2Ga = makeArrayGOpt(1, "");
~~~~~~~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
~~
!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
var a2Gb = makeArrayG<any>(1, "");
var a2Gc = makeArrayG<any[]>(1, ""); // error
~
@@ -1,6 +1,14 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(1,33): error TS2501: A rest element cannot contain a binding pattern.
tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,28): error TS2453: The type argument for type parameter 'V' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'boolean'.
tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,32): error TS2345: Argument of type '([string, number] | [string, boolean])[]' is not assignable to parameter of type 'Iterable<[string, number]>'.
Types of property '[Symbol.iterator]' are incompatible.
Type '() => IterableIterator<[string, number] | [string, boolean]>' is not assignable to type '() => Iterator<[string, number]>'.
Type 'IterableIterator<[string, number] | [string, boolean]>' is not assignable to type 'Iterator<[string, number]>'.
Types of property 'next' are incompatible.
Type '(value?: any) => IteratorResult<[string, number] | [string, boolean]>' is not assignable to type '(value?: any) => IteratorResult<[string, number]>'.
Type 'IteratorResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorResult<[string, number]>'.
Type '[string, number] | [string, boolean]' is not assignable to type '[string, number]'.
Type '[string, boolean]' is not assignable to type '[string, number]'.
Type 'boolean' is not assignable to type 'number'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts (2 errors) ====
@@ -8,6 +16,14 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,28): error
~~~~~~~~~~~~~~~~~~~~
!!! error TS2501: A rest element cannot contain a binding pattern.
takeFirstTwoEntries(...new Map([["", 0], ["hello", true]]));
~~~
!!! error TS2453: The type argument for type parameter 'V' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'boolean'.
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '([string, number] | [string, boolean])[]' is not assignable to parameter of type 'Iterable<[string, number]>'.
!!! error TS2345: Types of property '[Symbol.iterator]' are incompatible.
!!! error TS2345: Type '() => IterableIterator<[string, number] | [string, boolean]>' is not assignable to type '() => Iterator<[string, number]>'.
!!! error TS2345: Type 'IterableIterator<[string, number] | [string, boolean]>' is not assignable to type 'Iterator<[string, number]>'.
!!! error TS2345: Types of property 'next' are incompatible.
!!! error TS2345: Type '(value?: any) => IteratorResult<[string, number] | [string, boolean]>' is not assignable to type '(value?: any) => IteratorResult<[string, number]>'.
!!! error TS2345: Type 'IteratorResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorResult<[string, number]>'.
!!! error TS2345: Type '[string, number] | [string, boolean]' is not assignable to type '[string, number]'.
!!! error TS2345: Type '[string, boolean]' is not assignable to type '[string, number]'.
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.
@@ -1,5 +1,4 @@
tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts(28,1): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts(28,28): error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol'.
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts (1 errors) ====
@@ -31,6 +30,5 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts(28,1): error TS2453:
}
foo(...new SymbolIterator, ...new StringIterator);
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol'.
@@ -1,5 +1,4 @@
tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts(31,5): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts(31,32): error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol'.
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts (1 errors) ====
@@ -34,6 +33,5 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts(31,5): error TS2453:
}
new Foo(...new SymbolIterator, ...new StringIterator);
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol'.
@@ -1,5 +1,4 @@
tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts(31,5): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts(31,32): error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol'.
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts (1 errors) ====
@@ -34,7 +33,6 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts(31,5): error TS2453:
}
new Foo(...new SymbolIterator, ...[...new StringIterator]);
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'.
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol'.
@@ -1,5 +1,4 @@
tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(16,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'false'.
tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(16,42): error TS2345: Argument of type '"0"' is not assignable to parameter of type 'boolean'.
tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error TS2304: Cannot find name 'runTestCase'.
@@ -20,9 +19,8 @@ tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error T
var one = 1;
var _float = -(4/3);
var a = new Array(false,undefined,null,"0",obj,-1.3333333333333, "str",-0,true,+0, one, 1,0, false, _float, -(4/3));
~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'false'.
~~~
!!! error TS2345: Argument of type '"0"' is not assignable to parameter of type 'boolean'.
if (a.indexOf(-(4/3)) === 14 && // a[14]=_float===-(4/3)
a.indexOf(0) === 7 && // a[7] = +0, 0===+0
a.indexOf(-0) === 7 && // a[7] = +0, -0===+0
@@ -36,18 +36,18 @@ tests/cases/compiler/promisePermutations.ts(120,19): error TS2345: Argument of t
tests/cases/compiler/promisePermutations.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations.ts(122,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(126,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(129,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
tests/cases/compiler/promisePermutations.ts(129,33): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations.ts(134,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(137,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
tests/cases/compiler/promisePermutations.ts(144,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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
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>'.
tests/cases/compiler/promisePermutations.ts(137,33): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(144,35): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(152,36): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
Types of property 'then' are incompatible.
Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
@@ -260,10 +260,10 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~
!!! 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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@@ -278,9 +278,9 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~
!!! 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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
@@ -288,9 +288,9 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~
!!! 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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(x => x);
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@@ -299,14 +299,14 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
~~~~~~~~
!!! 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 '{ <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: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
@@ -36,18 +36,18 @@ tests/cases/compiler/promisePermutations2.ts(119,19): error TS2345: Argument of
tests/cases/compiler/promisePermutations2.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations2.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(125,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(128,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
tests/cases/compiler/promisePermutations2.ts(128,33): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations2.ts(131,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations2.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(136,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
tests/cases/compiler/promisePermutations2.ts(143,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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
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>'.
tests/cases/compiler/promisePermutations2.ts(136,33): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
tests/cases/compiler/promisePermutations2.ts(143,35): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
tests/cases/compiler/promisePermutations2.ts(151,36): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
Types of property 'then' are incompatible.
Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
@@ -259,10 +259,10 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~
!!! 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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@@ -277,9 +277,9 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~
!!! 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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
@@ -287,9 +287,9 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~~
!!! 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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(x => x);
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@@ -298,14 +298,14 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
~~~~~~~~
!!! 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 '{ <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: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
@@ -39,18 +39,18 @@ tests/cases/compiler/promisePermutations3.ts(119,19): error TS2345: Argument of
tests/cases/compiler/promisePermutations3.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations3.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(125,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(128,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(128,33): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations3.ts(131,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations3.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(136,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(143,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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
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>'.
tests/cases/compiler/promisePermutations3.ts(136,33): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(143,35): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(151,36): error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
Types of property 'then' are incompatible.
Type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
@@ -271,10 +271,10 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~
!!! 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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@@ -289,9 +289,9 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~
!!! 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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
@@ -299,9 +299,9 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~~
!!! 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 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => IPromise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'IPromise<number>'.
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(x => x);
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@@ -310,14 +310,14 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
~~~~~~~~
!!! 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 '{ <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: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
~~~~~~~~~
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
!!! error TS2345: Type 'IPromise<string>' is not assignable to type 'Promise<number>'.
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2345: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
@@ -1,8 +1,6 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(62,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(75,79): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(62,36): error TS2345: Argument of type '0' is not assignable to parameter of type '""'.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(75,79): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; z: Date; }'.
Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts (2 errors) ====
@@ -68,9 +66,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference
return null;
}
var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`;
~~~~~~~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'.
~
!!! error TS2345: Argument of type '0' is not assignable to parameter of type '""'.
var a9a: {};
// Generic tag with multiple parameters of generic type passed arguments with multiple best common types
@@ -85,9 +82,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference
var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`;
~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
!!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; z: Date; }'.
!!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
var a9e: {};
// Generic tag with multiple parameters of generic type passed arguments with a single best common type
@@ -1,8 +1,6 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(62,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(75,79): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(62,36): error TS2345: Argument of type '0' is not assignable to parameter of type '""'.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(75,79): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; z: Date; }'.
Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts (2 errors) ====
@@ -68,9 +66,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference
return null;
}
var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`;
~~~~~~~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'.
~
!!! error TS2345: Argument of type '0' is not assignable to parameter of type '""'.
var a9a: {};
// Generic tag with multiple parameters of generic type passed arguments with multiple best common types
@@ -85,9 +82,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference
var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`;
~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
!!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; z: Date; }'.
!!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
var a9e: {};
// Generic tag with multiple parameters of generic type passed arguments with a single best common type
@@ -8,13 +8,15 @@ tests/cases/conformance/jsx/file.tsx(20,19): error TS2322: Type '{ func: (a: num
Type '{ func: (a: number, b: string) => void; }' is not assignable to type '{ func: (arg: number) => void; }'.
Types of property 'func' are incompatible.
Type '(a: number, b: string) => void' is not assignable to type '(arg: number) => void'.
tests/cases/conformance/jsx/file.tsx(31,9): error TS2605: JSX element type 'Element' is not a constructor function for JSX elements.
Property 'render' is missing in type 'Element'.
tests/cases/conformance/jsx/file.tsx(31,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/conformance/jsx/file.tsx(31,30): error TS2322: Type '{ values: number[]; selectHandler: (val: string) => void; }' is not assignable to type 'IntrinsicAttributes & InferParamProp<number>'.
Type '{ values: number[]; selectHandler: (val: string) => void; }' is not assignable to type 'InferParamProp<number>'.
Types of property 'selectHandler' are incompatible.
Type '(val: string) => void' is not assignable to type '(selectedVal: number) => void'.
Types of parameters 'val' and 'selectedVal' are incompatible.
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/jsx/file.tsx (5 errors) ====
==== tests/cases/conformance/jsx/file.tsx (4 errors) ====
import React = require('react')
declare function ComponentSpecific1<U>(l: {prop: U, "ignore-prop": string}): JSX.Element;
@@ -59,10 +61,11 @@ tests/cases/conformance/jsx/file.tsx(31,10): error TS2453: The type argument for
// Error
let i = <InferParamComponent values={[1, 2, 3, 4]} selectHandler={(val: string) => { }} />;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2605: JSX element type 'Element' is not a constructor function for JSX elements.
!!! error TS2605: Property 'render' is missing in type 'Element'.
~~~~~~~~~~~~~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type '{ values: number[]; selectHandler: (val: string) => void; }' is not assignable to type 'IntrinsicAttributes & InferParamProp<number>'.
!!! error TS2322: Type '{ values: number[]; selectHandler: (val: string) => void; }' is not assignable to type 'InferParamProp<number>'.
!!! error TS2322: Types of property 'selectHandler' are incompatible.
!!! error TS2322: Type '(val: string) => void' is not assignable to type '(selectedVal: number) => void'.
!!! error TS2322: Types of parameters 'val' and 'selectedVal' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
@@ -1,11 +1,7 @@
tests/cases/conformance/jsx/file.tsx(15,14): error TS2605: JSX element type 'Element' is not a constructor function for JSX elements.
Property 'render' is missing in type 'Element'.
tests/cases/conformance/jsx/file.tsx(15,15): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate '"hello"'.
tests/cases/conformance/jsx/file.tsx(16,42): error TS2339: Property 'prop1' does not exist on type 'IntrinsicAttributes & { prop: number; }'.
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
import React = require('react')
declare function Component<U>(l: U): JSX.Element;
@@ -21,12 +17,6 @@ tests/cases/conformance/jsx/file.tsx(16,42): error TS2339: Property 'prop1' does
let a1 = <ComponentSpecific {...arg} ignore-prop="hi" />; // U is number
let a2 = <ComponentSpecific1 {...arg} ignore-prop={10} />; // U is number
let a3 = <ComponentSpecific {...arg} prop="hello" />; // U is "hello"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2605: JSX element type 'Element' is not a constructor function for JSX elements.
!!! error TS2605: Property 'render' is missing in type 'Element'.
~~~~~~~~~~~~~~~~~
!!! 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 'number' is not a valid type argument because it is not a supertype of candidate '"hello"'.
let a4 = <ComponentSpecific {...arg} prop1="hello" />; // U is "hello"
~~~~~~~~~~~~~
!!! error TS2339: Property 'prop1' does not exist on type 'IntrinsicAttributes & { prop: number; }'.
@@ -1,6 +1,5 @@
tests/cases/compiler/typeArgInference2.ts(12,52): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'.
Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'.
tests/cases/compiler/typeArgInference2.ts(12,52): error TS2345: Argument of type '{ name: string; b: number; }' is not assignable to parameter of type '{ name: string; a: number; }'.
Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'.
==== tests/cases/compiler/typeArgInference2.ts (1 errors) ====
@@ -17,6 +16,5 @@ tests/cases/compiler/typeArgInference2.ts(12,52): error TS2453: The type argumen
var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number }
var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // error
~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'.
!!! error TS2453: Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'.
!!! error TS2345: Argument of type '{ name: string; b: number; }' is not assignable to parameter of type '{ name: string; a: number; }'.
!!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'.
@@ -1,5 +1,4 @@
tests/cases/compiler/typeArgInference2WithError.ts(7,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '"abc"' is not a valid type argument because it is not a supertype of candidate '5'.
tests/cases/compiler/typeArgInference2WithError.ts(7,14): error TS2345: Argument of type '"abc"' is not assignable to parameter of type 'Item'.
==== tests/cases/compiler/typeArgInference2WithError.ts (1 errors) ====
@@ -10,6 +9,5 @@ tests/cases/compiler/typeArgInference2WithError.ts(7,10): error TS2453: The type
declare function foo<T extends Item>(x?: T, y?: T): T;
var z7 = foo("abc", 5); // Error
~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '"abc"' is not a valid type argument because it is not a supertype of candidate '5'.
~~~~~
!!! error TS2345: Argument of type '"abc"' is not assignable to parameter of type 'Item'.
@@ -1,8 +1,6 @@
tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(68,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,69): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(68,29): error TS2345: Argument of type '0' is not assignable to parameter of type '""'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,69): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; z: Date; }'.
Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,74): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'.
Object literal may only specify known properties, and 'y' does not exist in type 'A92'.
@@ -76,9 +74,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,74
return null;
}
var a9a = someGenerics9('', 0, []);
~~~~~~~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'.
~
!!! error TS2345: Argument of type '0' is not assignable to parameter of type '""'.
var a9a: {};
var a9b = someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null);
var a9b: { a?: number; b?: string; };
@@ -94,9 +91,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,74
}
var a9e = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' });
~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
!!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; z: Date; }'.
!!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'.
var a9e: {};
var a9f = someGenerics9<A92>(undefined, { x: 6, z: new Date() }, { x: 6, y: '' });
~~~~~
@@ -9,13 +9,11 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(81,45): error TS2345: Argument of type '(n: string) => string' is not assignable to parameter of type '(b: number) => number'.
Types of parameters 'n' and 'b' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(106,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(106,33): error TS2345: Argument of type '0' is not assignable to parameter of type '""'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(118,9): error TS2304: Cannot find name 'Window'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,51): error TS2304: Cannot find name 'window'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,69): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,69): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; z: any; }'.
Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,56): error TS2304: Cannot find name 'window'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,74): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'.
Object literal may only specify known properties, and 'y' does not exist in type 'A92'.
@@ -144,9 +142,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct
}
var someGenerics9: someGenerics9;
var a9a = new someGenerics9('', 0, []);
~~~~~~~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'.
~
!!! error TS2345: Argument of type '0' is not assignable to parameter of type '""'.
var a9a: {};
var a9b = new someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null);
var a9b: { a?: number; b?: string; };
@@ -166,9 +163,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct
~~~~~~
!!! error TS2304: Cannot find name 'window'.
~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
!!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'.
!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; z: any; }'.
!!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'.
var a9e: {};
var a9f = new someGenerics9<A92>(undefined, { x: 6, z: window }, { x: 6, y: '' });
~~~~~~
@@ -1,6 +1,5 @@
tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts(7,1): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'Giraffe' is not a valid type argument because it is not a supertype of candidate 'Elephant'.
Property 'y' is missing in type 'Elephant'.
tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts(7,6): error TS2345: Argument of type 'Elephant' is not assignable to parameter of type 'Giraffe'.
Property 'y' is missing in type 'Elephant'.
==== tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts (1 errors) ====
@@ -11,7 +10,6 @@ tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts(7,1): er
var g: Giraffe;
var e: Elephant;
f(g, e); // valid because both Giraffe and Elephant satisfy the constraint. T is Animal
~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'Giraffe' is not a valid type argument because it is not a supertype of candidate 'Elephant'.
!!! error TS2453: Property 'y' is missing in type 'Elephant'.
~
!!! error TS2345: Argument of type 'Elephant' is not assignable to parameter of type 'Giraffe'.
!!! error TS2345: Property 'y' is missing in type 'Elephant'.
@@ -14,13 +14,11 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst
Types of parameters 'n' and 'b' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(66,31): error TS2345: Argument of type '<A, B extends string, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void' is not assignable to parameter of type 'string'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(73,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(73,29): error TS2345: Argument of type '0' is not assignable to parameter of type '""'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(85,9): error TS2304: Cannot find name 'Window'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,47): error TS2304: Cannot find name 'window'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,65): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,65): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; z: any; }'.
Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,52): error TS2304: Cannot find name 'window'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,70): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'.
Object literal may only specify known properties, and 'y' does not exist in type 'A92'.
@@ -126,9 +124,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst
return null;
}
var a9a = someGenerics9('', 0, []);
~~~~~~~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'.
~
!!! error TS2345: Argument of type '0' is not assignable to parameter of type '""'.
var a9a: {};
var a9b = someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null);
var a9b: { a?: number; b?: string; };
@@ -148,9 +145,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst
~~~~~~
!!! error TS2304: Cannot find name 'window'.
~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
!!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'.
!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; z: any; }'.
!!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'.
var a9e: {};
var a9f = someGenerics9<A92>(undefined, { x: 6, z: window }, { x: 6, y: '' });
~~~~~~
@@ -1,5 +1,4 @@
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts(35,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'E1' is not a valid type argument because it is not a supertype of candidate 'E2'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts(35,43): error TS2345: Argument of type 'E2' is not assignable to parameter of type 'E1'.
==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts (1 errors) ====
@@ -38,7 +37,6 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjec
var v2 = f1({ w: x => x, r: () => E1.X }, E1.X);
var v3 = f1({ w: x => x, r: () => E1.X }, E2.X); // Error
~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'E1' is not a valid type argument because it is not a supertype of candidate 'E2'.
~~~~
!!! error TS2345: Argument of type 'E2' is not assignable to parameter of type 'E1'.
@@ -1,11 +1,9 @@
tests/cases/compiler/typeInferenceConflictingCandidates.ts(3,1): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '3'.
tests/cases/compiler/typeInferenceConflictingCandidates.ts(3,7): error TS2345: Argument of type '3' is not assignable to parameter of type '""'.
==== tests/cases/compiler/typeInferenceConflictingCandidates.ts (1 errors) ====
declare function g<T>(a: T, b: T, c: (t: T) => T): T;
g("", 3, a => a);
~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '3'.
~
!!! error TS2345: Argument of type '3' is not assignable to parameter of type '""'.
+1 -1
View File
@@ -15,5 +15,5 @@
verify.quickInfos({
1: "function ComponentSpecific<number>(l: {\n prop: number;\n}): any",
2: "function ComponentSpecific<U>(l: {\n prop: U;\n}): any"
2: "function ComponentSpecific<number>(l: {\n prop: number;\n}): any"
});
+2 -2
View File
@@ -24,6 +24,6 @@ verify.quickInfos({
3: "function OverloadComponent<boolean, string>(attr: {\n b: string;\n a: boolean;\n}): any (+2 overloads)",
4: "function OverloadComponent<number>(attr: {\n b: number;\n a?: string;\n \"ignore-prop\": boolean;\n}): any (+2 overloads)",
5: "function OverloadComponent(): any (+2 overloads)",
6: "function OverloadComponent(): any (+2 overloads)",
7: "function OverloadComponent(): any (+2 overloads)",
6: "function OverloadComponent<boolean, string>(attr: {\n b: string;\n a: boolean;\n}): any (+2 overloads)",
7: "function OverloadComponent<boolean, number>(attr: {\n b: number;\n a: boolean;\n}): any (+2 overloads)",
});