Expand constraint suggestion related span and add quick fix (#49481)

* Expand constraint suggestion related span and add quick fix

* Remove circular constraint suggestions

* Add error code

* Style feedback and new error code in quickfix
This commit is contained in:
Wesley Wigham
2022-06-15 10:35:51 -07:00
committed by GitHub
parent eb4b8a4d2e
commit ba38fe1df2
80 changed files with 336 additions and 13 deletions
+7 -2
View File
@@ -18806,8 +18806,13 @@ namespace ts {
return;
}
reportRelationError(headMessage, source, target);
if (strictNullChecks && source.flags & TypeFlags.TypeVariable && source.symbol?.declarations?.[0] && !getConstraintOfType(source as TypeVariable) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~TypeFlags.NonPrimitive))) {
associateRelatedInfo(createDiagnosticForNode(source.symbol.declarations[0], Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
if (source.flags & TypeFlags.TypeParameter && source.symbol?.declarations?.[0] && !getConstraintOfType(source as TypeVariable)) {
const syntheticParam = cloneTypeParameter(source as TypeParameter);
syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
if (hasNonCircularBaseConstraint(syntheticParam)) {
const targetConstraintString = typeToString(target, source.symbol.declarations[0]);
associateRelatedInfo(createDiagnosticForNode(source.symbol.declarations[0], Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
}
}
}
+9 -1
View File
@@ -1530,7 +1530,7 @@
"category": "Error",
"code": 2207
},
"This type parameter probably needs an `extends object` constraint.": {
"This type parameter might need an `extends {0}` constraint.": {
"category": "Error",
"code": 2208
},
@@ -1543,6 +1543,14 @@
"category": "Error",
"code": 2210
},
"Add `extends` constraint.": {
"category": "Message",
"code": 2211
},
"Add `extends` constraint to all type parameters": {
"category": "Message",
"code": 2212
},
"Duplicate identifier '{0}'.": {
"category": "Error",
@@ -0,0 +1,65 @@
/* @internal */
namespace ts.codefix {
const fixId = "addMissingConstraint";
const errorCodes = [
// We want errors this could be attached to:
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
Diagnostics.Type_0_is_not_comparable_to_type_1.code,
Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated.code,
Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
Diagnostics.Property_0_is_incompatible_with_index_signature.code,
Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code,
Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code,
];
registerCodeFix({
errorCodes,
getCodeActions(context) {
const { sourceFile, span, program } = context;
const related = getDiagnosticRelatedInfo(program, sourceFile, span);
if (!related) {
return;
}
const changes = textChanges.ChangeTracker.with(context, t => addMissingConstraint(t, related));
return [createCodeFixAction(fixId, changes, Diagnostics.Add_extends_constraint, fixId, Diagnostics.Add_extends_constraint_to_all_type_parameters)];
},
fixIds: [fixId],
getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => {
const info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag);
if (!info) return;
return addMissingConstraint(changes, info);
}),
});
function getDiagnosticRelatedInfo(program: Program, sourceFile: SourceFile, span: TextSpan) {
const diag = find(program.getSemanticDiagnostics(sourceFile), diag => diag.start === span.start && diag.length === span.length);
if (!diag || !diag.relatedInformation) return;
const related = find(diag.relatedInformation, related => related.code === Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code);
if (!related) return;
return related;
}
function addMissingConstraint(changes: textChanges.ChangeTracker, related: DiagnosticRelatedInformation): void {
let decl = findAncestorMatchingSpan(related.file!, related as TextSpan);
if (!decl) return;
if (isIdentifier(decl) && isTypeParameterDeclaration(decl.parent)) {
decl = decl.parent;
}
if (!isTypeParameterDeclaration(decl) || isMappedTypeNode(decl.parent)) return; // should only issue fix on type parameters written using `extends`
const newConstraint = flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
if (!newConstraint) return;
const newConstraintText = newConstraint[1];
changes.insertText(related.file!, related.start! + related.length!, ` extends ${newConstraintText}`);
}
function findAncestorMatchingSpan(sourceFile: SourceFile, span: TextSpan): Node {
let token = getTokenAtPosition(sourceFile, span.start);
const end = textSpanEnd(span);
while (token.end < end) {
token = token.parent;
}
return token;
}
}
+1
View File
@@ -68,6 +68,7 @@
"codefixes/convertLiteralTypeToMappedType.ts",
"codefixes/fixClassIncorrectlyImplementsInterface.ts",
"codefixes/importFixes.ts",
"codefixes/fixAddMissingConstraint.ts",
"codefixes/fixOverrideModifier.ts",
"codefixes/fixNoPropertyAccessFromIndexSignature.ts",
"codefixes/fixImplicitThis.ts",
@@ -114,6 +114,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '(x: number) => number[]' is not assignable to type '<T>(x: T) => T[]'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts:45:9: This type parameter might need an `extends number` constraint.
var b2: <T>(x: T) => string[];
a2 = b2; // ok
b2 = a2; // ok
@@ -121,6 +122,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '(x: number) => string[]' is not assignable to type '<T>(x: T) => string[]'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts:48:10: This type parameter might need an `extends number` constraint.
var b3: <T>(x: T) => T;
a3 = b3; // ok
b3 = a3; // ok
@@ -128,6 +130,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '(x: number) => void' is not assignable to type '<T>(x: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts:51:10: This type parameter might need an `extends number` constraint.
var b4: <T, U>(x: T, y: U) => T;
a4 = b4; // ok
b4 = a4; // ok
@@ -135,6 +138,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '(x: string, y: number) => string' is not assignable to type '<T, U>(x: T, y: U) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts:54:10: This type parameter might need an `extends string` constraint.
var b5: <T, U>(x: (arg: T) => U) => T;
a5 = b5; // ok
b5 = a5; // ok
@@ -227,6 +231,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'.
!!! error TS2322: Types of property 'a' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts:84:11: This type parameter might need an `extends string` constraint.
var b15: <T>(x: T) => T[];
a15 = b15; // ok
b15 = a15; // ok
@@ -113,6 +113,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '(x: number) => string[]' is not assignable to type '<T, U>(x: T) => U[]'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts:43:18: This type parameter might need an `extends number` constraint.
var b7: <T extends Base, U extends Derived, V extends Derived2>(x: (arg: T) => U) => (r: T) => V;
a7 = b7;
@@ -181,6 +182,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'.
!!! error TS2322: Types of property 'a' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts:68:19: This type parameter might need an `extends string` constraint.
var b15a: <T extends Base>(x: { a: T; b: T }) => number;
a15 = b15a;
@@ -223,6 +225,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '<T>(x: T) => T[]' is not assignable to type '<T>(x: T) => string[]'.
!!! error TS2322: Type 'T[]' is not assignable to type 'string[]'.
!!! error TS2322: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts:88:18: This type parameter might need an `extends string` constraint.
// target type has generic call signature
var a3: <T>(x: T) => string[];
@@ -232,6 +235,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '<T>(x: T) => T[]' is not assignable to type '<T>(x: T) => string[]'.
!!! error TS2322: Type 'T[]' is not assignable to type 'string[]'.
!!! error TS2322: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts:93:18: This type parameter might need an `extends string` constraint.
b3 = a3;
~~
!!! error TS2322: Type '<T>(x: T) => string[]' is not assignable to type '<T>(x: T) => T[]'.
@@ -84,6 +84,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts:50:14: This type parameter might need an `extends T` constraint.
var b15: <U, V>(x: { a: U; b: V; }) => U[];
a15 = b15; // ok, T = U, T = V
b15 = a15; // ok
@@ -94,6 +95,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Types of property 'b' are incompatible.
!!! error TS2322: Type 'V' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts:53:14: This type parameter might need an `extends U` constraint.
var b16: <T>(x: { a: T; b: T }) => T[];
a15 = b16; // ok
b15 = a16; // ok
@@ -103,6 +105,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'.
!!! error TS2322: Types of property 'a' are incompatible.
!!! error TS2322: Type 'U' is not assignable to type 'Base'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts:53:11: This type parameter might need an `extends Base` constraint.
var b17: <T>(x: (a: T) => T) => T[];
a17 = b17; // ok
b17 = a17; // ok
@@ -65,6 +65,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts:37:14: This type parameter might need an `extends T` constraint.
var b16: <T>(x: { a: T; b: T }) => T[];
x.a16 = b16;
b16 = x.a16;
@@ -73,4 +74,5 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'.
!!! error TS2322: Types of property 'a' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'Base'.
!!! error TS2322: Type 'T' is not assignable to type 'Base'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts:40:11: This type parameter might need an `extends Base` constraint.
@@ -114,6 +114,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'new (x: number) => number[]' is not assignable to type 'new <T>(x: T) => T[]'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts:45:13: This type parameter might need an `extends number` constraint.
var b2: new <T>(x: T) => string[];
a2 = b2; // ok
b2 = a2; // ok
@@ -121,6 +122,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'new (x: number) => string[]' is not assignable to type 'new <T>(x: T) => string[]'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts:48:14: This type parameter might need an `extends number` constraint.
var b3: new <T>(x: T) => T;
a3 = b3; // ok
b3 = a3; // ok
@@ -128,6 +130,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'new (x: number) => void' is not assignable to type 'new <T>(x: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts:51:14: This type parameter might need an `extends number` constraint.
var b4: new <T, U>(x: T, y: U) => T;
a4 = b4; // ok
b4 = a4; // ok
@@ -135,6 +138,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'new (x: string, y: number) => string' is not assignable to type 'new <T, U>(x: T, y: U) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts:54:14: This type parameter might need an `extends string` constraint.
var b5: new <T, U>(x: (arg: T) => U) => T;
a5 = b5; // ok
b5 = a5; // ok
@@ -227,6 +231,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'.
!!! error TS2322: Types of property 'a' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts:84:15: This type parameter might need an `extends string` constraint.
var b15: new <T>(x: T) => T[];
a15 = b15; // ok
b15 = a15; // ok
@@ -129,6 +129,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'new (x: number) => string[]' is not assignable to type 'new <T, U>(x: T) => U[]'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts:43:22: This type parameter might need an `extends number` constraint.
var b7: new <T extends Base, U extends Derived, V extends Derived2>(x: (arg: T) => U) => (r: T) => V;
a7 = b7; // ok
@@ -197,6 +198,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'.
!!! error TS2322: Types of property 'a' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts:68:23: This type parameter might need an `extends string` constraint.
var b15a: new <T extends Base>(x: { a: T; b: T }) => number;
a15 = b15a; // ok
@@ -259,6 +261,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'new <T>(x: T) => T[]' is not assignable to type 'new <T>(x: T) => string[]'.
!!! error TS2322: Type 'T[]' is not assignable to type 'string[]'.
!!! error TS2322: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts:88:22: This type parameter might need an `extends string` constraint.
// target type has generic call signature
var a3: new <T>(x: T) => string[];
@@ -268,6 +271,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'new <T>(x: T) => T[]' is not assignable to type 'new <T>(x: T) => string[]'.
!!! error TS2322: Type 'T[]' is not assignable to type 'string[]'.
!!! error TS2322: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts:93:22: This type parameter might need an `extends string` constraint.
b3 = a3; // ok
~~
!!! error TS2322: Type 'new <T>(x: T) => string[]' is not assignable to type 'new <T>(x: T) => T[]'.
@@ -84,6 +84,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts:50:18: This type parameter might need an `extends T` constraint.
var b15: new <U, V>(x: { a: U; b: V; }) => U[];
a15 = b15; // ok
b15 = a15; // ok
@@ -94,6 +95,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Types of property 'b' are incompatible.
!!! error TS2322: Type 'V' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts:53:18: This type parameter might need an `extends U` constraint.
var b16: new <T>(x: { a: T; b: T }) => T[];
a15 = b16; // ok
b15 = a16; // ok
@@ -103,6 +105,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'.
!!! error TS2322: Types of property 'a' are incompatible.
!!! error TS2322: Type 'U' is not assignable to type 'Base'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts:53:15: This type parameter might need an `extends Base` constraint.
var b17: new <T>(x: new (a: T) => T) => T[];
a17 = b17; // ok
b17 = a17; // ok
@@ -65,6 +65,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts:37:18: This type parameter might need an `extends T` constraint.
var b16: new <T>(x: { a: T; b: T }) => T[];
x.a16 = b16;
b16 = x.a16;
@@ -73,4 +74,5 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'.
!!! error TS2322: Types of property 'a' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'Base'.
!!! error TS2322: Type 'T' is not assignable to type 'Base'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts:40:15: This type parameter might need an `extends Base` constraint.
@@ -33,4 +33,5 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'A' is not assignable to type 'B'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type 'S' is not assignable to type 'S[]'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts:8:6: This type parameter might need an `extends S[]` constraint.
@@ -163,11 +163,13 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '() => T' is not assignable to type '<T>() => T'.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:58:18: This type parameter might need an `extends T` constraint.
b.a = t.a2;
~~~
!!! error TS2322: Type '(x?: T) => T' is not assignable to type '<T>() => T'.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:58:18: This type parameter might need an `extends T` constraint.
b.a = t.a3;
~~~
!!! error TS2322: Type '(x: T) => T' is not assignable to type '<T>() => T'.
@@ -179,126 +181,147 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '<T>() => T'.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:58:18: This type parameter might need an `extends T` constraint.
b.a2 = t.a;
~~~~
!!! error TS2322: Type '() => T' is not assignable to type '<T>(x?: T) => T'.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:58:18: This type parameter might need an `extends T` constraint.
b.a2 = t.a2;
~~~~
!!! error TS2322: Type '(x?: T) => T' is not assignable to type '<T>(x?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:43:14: This type parameter might need an `extends T` constraint.
b.a2 = t.a3;
~~~~
!!! error TS2322: Type '(x: T) => T' is not assignable to type '<T>(x?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:43:14: This type parameter might need an `extends T` constraint.
b.a2 = t.a4;
~~~~
!!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '<T>(x?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:43:14: This type parameter might need an `extends T` constraint.
b.a2 = t.a5;
~~~~
!!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '<T>(x?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:43:14: This type parameter might need an `extends T` constraint.
b.a3 = t.a;
~~~~
!!! error TS2322: Type '() => T' is not assignable to type '<T>(x: T) => T'.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:58:18: This type parameter might need an `extends T` constraint.
b.a3 = t.a2;
~~~~
!!! error TS2322: Type '(x?: T) => T' is not assignable to type '<T>(x: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:44:14: This type parameter might need an `extends T` constraint.
b.a3 = t.a3;
~~~~
!!! error TS2322: Type '(x: T) => T' is not assignable to type '<T>(x: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:44:14: This type parameter might need an `extends T` constraint.
b.a3 = t.a4;
~~~~
!!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '<T>(x: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:44:14: This type parameter might need an `extends T` constraint.
b.a3 = t.a5;
~~~~
!!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '<T>(x: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:44:14: This type parameter might need an `extends T` constraint.
b.a4 = t.a;
~~~~
!!! error TS2322: Type '() => T' is not assignable to type '<T>(x: T, y?: T) => T'.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:58:18: This type parameter might need an `extends T` constraint.
b.a4 = t.a2;
~~~~
!!! error TS2322: Type '(x?: T) => T' is not assignable to type '<T>(x: T, y?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:45:14: This type parameter might need an `extends T` constraint.
b.a4 = t.a3;
~~~~
!!! error TS2322: Type '(x: T) => T' is not assignable to type '<T>(x: T, y?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:45:14: This type parameter might need an `extends T` constraint.
b.a4 = t.a4;
~~~~
!!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '<T>(x: T, y?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:45:14: This type parameter might need an `extends T` constraint.
b.a4 = t.a5;
~~~~
!!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '<T>(x: T, y?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:45:14: This type parameter might need an `extends T` constraint.
b.a5 = t.a;
~~~~
!!! error TS2322: Type '() => T' is not assignable to type '<T>(x?: T, y?: T) => T'.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:58:18: This type parameter might need an `extends T` constraint.
b.a5 = t.a2;
~~~~
!!! error TS2322: Type '(x?: T) => T' is not assignable to type '<T>(x?: T, y?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:46:14: This type parameter might need an `extends T` constraint.
b.a5 = t.a3;
~~~~
!!! error TS2322: Type '(x: T) => T' is not assignable to type '<T>(x?: T, y?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:46:14: This type parameter might need an `extends T` constraint.
b.a5 = t.a4;
~~~~
!!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '<T>(x?: T, y?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:46:14: This type parameter might need an `extends T` constraint.
b.a5 = t.a5;
~~~~
!!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '<T>(x?: T, y?: T) => T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts:46:14: This type parameter might need an `extends T` constraint.
}
}
@@ -17,5 +17,6 @@ tests/cases/compiler/assignmentStricterConstraints.ts(7,1): error TS2322: Type '
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type 'S' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'S'.
!!! related TS2208 tests/cases/compiler/assignmentStricterConstraints.ts:5:22: This type parameter might need an `extends T` constraint.
g(1, "")
@@ -190,6 +190,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
!!! error TS2430: The types returned by 'a2(...)' are incompatible between these types.
!!! error TS2430: Type 'T[]' is not assignable to type 'string[]'.
!!! error TS2430: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts:106:18: This type parameter might need an `extends string` constraint.
a2: <T>(x: T) => T[]; // error
}
}
@@ -79,6 +79,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts:12:9: This type parameter might need an `extends T` constraint.
a: (x: T) => T[];
}
@@ -90,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts:13:10: This type parameter might need an `extends T` constraint.
a2: (x: T) => string[];
}
@@ -101,6 +103,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts:14:10: This type parameter might need an `extends T` constraint.
a3: (x: T) => T;
}
@@ -112,6 +115,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts:15:10: This type parameter might need an `extends T` constraint.
a4: <U>(x: T, y: U) => string;
}
@@ -124,6 +128,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
!!! error TS2430: Types of parameters 'arg' and 'arg' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts:40:14: This type parameter might need an `extends T` constraint.
a5: <U>(x: (arg: T) => U) => T;
}
@@ -137,6 +142,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
!!! error TS2430: Types of property 'foo' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts:18:11: This type parameter might need an `extends T` constraint.
a11: <U>(x: { foo: T }, y: { foo: U; bar: U }) => Base;
}
@@ -18,6 +18,7 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete
~
!!! error TS2322: Type 'T' is not assignable to type 'S'.
!!! error TS2322: 'S' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts:1:13: This type parameter might need an `extends S` constraint.
!!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts:3:27: The expected type comes from the return type of this signature.
// But error to try to climb up the chain
@@ -25,6 +26,7 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete
~
!!! error TS2322: Type 'T' is not assignable to type 'S'.
!!! error TS2322: 'S' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts:1:13: This type parameter might need an `extends S` constraint.
!!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts:3:27: The expected type comes from the return type of this signature.
// Staying at T or S should be fine
@@ -21,4 +21,5 @@ tests/cases/conformance/expressions/commaOperator/commaOperatorOtherInvalidOpera
~~~~~~
!!! error TS2322: Type 'T2' is not assignable to type 'T1'.
!!! error TS2322: 'T1' could be instantiated with an arbitrary type which could be unrelated to 'T2'.
!!! related TS2208 tests/cases/conformance/expressions/commaOperator/commaOperatorOtherInvalidOperation.ts:9:19: This type parameter might need an `extends T1` constraint.
}
@@ -17,4 +17,5 @@ tests/cases/compiler/conditionalTypeVarianceBigArrayConstraintsPerformance.ts(9,
!!! error TS2322: Type 'Stuff<U>' is not assignable to type 'Stuff<T>'.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/compiler/conditionalTypeVarianceBigArrayConstraintsPerformance.ts:8:15: This type parameter might need an `extends T` constraint.
}
@@ -84,7 +84,7 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS
~
!!! error TS2322: Type 'T' is not assignable to type 'NonNullable<T>'.
!!! error TS2322: Type 'T' is not assignable to type '{}'.
!!! related TS2208 tests/cases/conformance/types/conditional/conditionalTypes1.ts:10:13: This type parameter probably needs an `extends object` constraint.
!!! related TS2208 tests/cases/conformance/types/conditional/conditionalTypes1.ts:10:13: This type parameter might need an `extends {}` constraint.
}
function f2<T extends string | undefined>(x: T, y: NonNullable<T>) {
@@ -55,6 +55,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2
!!! error TS2322: Type 'Covariant<A>' is not assignable to type 'Covariant<B>'.
!!! error TS2322: Type 'A' is not assignable to type 'B'.
!!! error TS2322: 'B' could be instantiated with an arbitrary type which could be unrelated to 'A'.
!!! related TS2208 tests/cases/conformance/types/conditional/conditionalTypes2.ts:13:13: This type parameter might need an `extends B` constraint.
}
function f2<A, B extends A>(a: Contravariant<A>, b: Contravariant<B>) {
@@ -63,6 +64,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2
!!! error TS2322: Type 'Contravariant<B>' is not assignable to type 'Contravariant<A>'.
!!! error TS2322: Type 'A' is not assignable to type 'B'.
!!! error TS2322: 'B' could be instantiated with an arbitrary type which could be unrelated to 'A'.
!!! related TS2208 tests/cases/conformance/types/conditional/conditionalTypes2.ts:18:13: This type parameter might need an `extends B` constraint.
b = a;
}
@@ -91,6 +93,8 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2
!!! error TS2322: Type 'A' is not assignable to type 'B extends string ? keyof B : B'.
!!! error TS2322: Type 'A' is not assignable to type 'B'.
!!! error TS2322: 'B' could be instantiated with an arbitrary type which could be unrelated to 'A'.
!!! related TS2208 tests/cases/conformance/types/conditional/conditionalTypes2.ts:23:13: This type parameter might need an `extends B` constraint.
!!! related TS2208 tests/cases/conformance/types/conditional/conditionalTypes2.ts:23:13: This type parameter might need an `extends B extends string ? keyof B : B` constraint.
}
// Extract<T, Function> is a T that is known to be a Function
@@ -176,6 +176,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
!!! error TS2430: The types returned by 'new a2(...)' are incompatible between these types.
!!! error TS2430: Type 'T[]' is not assignable to type 'string[]'.
!!! error TS2430: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts:92:22: This type parameter might need an `extends string` constraint.
a2: new <T>(x: T) => T[]; // error
}
@@ -79,6 +79,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts:12:13: This type parameter might need an `extends T` constraint.
a: new (x: T) => T[];
}
@@ -90,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts:13:14: This type parameter might need an `extends T` constraint.
a2: new (x: T) => string[];
}
@@ -101,6 +103,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts:14:14: This type parameter might need an `extends T` constraint.
a3: new (x: T) => T;
}
@@ -112,6 +115,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts:15:14: This type parameter might need an `extends T` constraint.
a4: new <U>(x: T, y: U) => string;
}
@@ -124,6 +128,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
!!! error TS2430: Types of parameters 'arg' and 'arg' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts:40:14: This type parameter might need an `extends T` constraint.
a5: new <U>(x: (arg: T) => U) => T;
}
@@ -137,6 +142,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
!!! error TS2430: Types of property 'foo' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts:18:15: This type parameter might need an `extends T` constraint.
a11: new <U>(x: { foo: T }, y: { foo: U; bar: U }) => Base;
}
@@ -26,6 +26,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co
~~~~~~~~~~~~~~~
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts:8:9: This type parameter might need an `extends U` constraint.
var z = x;
}
}
@@ -19,6 +19,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericC
~~~~~~~~
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts:6:15: This type parameter might need an `extends U` constraint.
function foo5<T, U extends T>(x: U, y: T = x) { } // ok
function foo6<T, U extends T, V extends U>(x: T, y: U, z: V = y) { } // error
~~~~~~~~
@@ -37,6 +37,7 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(14,17
~
!!! error TS2345: Argument of type 'U' is not assignable to parameter of type 'T'.
!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts:1:17: This type parameter might need an `extends T` constraint.
var r22 = f<number>(y);
~~~~~~
!!! error TS2558: Expected 0 type arguments, but got 1.
@@ -39,6 +39,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(42,29): error TS2716: Type paramet
declare function f05<T, U extends number = T>(): void; // error
~
!!! error TS2344: Type 'T' does not satisfy the constraint 'number'.
!!! related TS2208 tests/cases/compiler/genericDefaultsErrors.ts:5:22: This type parameter might need an `extends number` constraint.
declare function f06<T, U extends T = number>(): void; // error
~~~~~~
!!! error TS2344: Type 'number' does not satisfy the constraint 'T'.
@@ -88,6 +89,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(42,29): error TS2716: Type paramet
interface i07<T, U extends number = T> { } // error
~
!!! error TS2344: Type 'T' does not satisfy the constraint 'number'.
!!! related TS2208 tests/cases/compiler/genericDefaultsErrors.ts:28:15: This type parameter might need an `extends number` constraint.
interface i08<T, U extends T = number> { } // error
~~~~~~
!!! error TS2344: Type 'number' does not satisfy the constraint 'T'.
@@ -20,6 +20,7 @@ tests/cases/compiler/genericSpecializations1.ts(10,5): error TS2416: Property 'f
!!! error TS2416: Type '(x: string) => string' is not assignable to type '<T>(x: T) => T'.
!!! error TS2416: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2416: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/compiler/genericSpecializations1.ts:2:9: This type parameter might need an `extends string` constraint.
}
class StringFoo2 implements IFoo<string> {
@@ -29,6 +30,7 @@ tests/cases/compiler/genericSpecializations1.ts(10,5): error TS2416: Property 'f
!!! error TS2416: Type '(x: string) => string' is not assignable to type '<T>(x: T) => T'.
!!! error TS2416: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2416: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/compiler/genericSpecializations1.ts:2:9: This type parameter might need an `extends string` constraint.
}
class StringFoo3 implements IFoo<string> {
@@ -24,6 +24,7 @@ tests/cases/compiler/genericSpecializations2.ts(12,9): error TS2368: Type parame
!!! error TS2416: Type '<string>(x: string) => string' is not assignable to type '<T>(x: T) => T'.
!!! error TS2416: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2416: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/compiler/genericSpecializations2.ts:2:9: This type parameter might need an `extends string` constraint.
~~~~~~
!!! error TS2368: Type parameter name cannot be 'string'.
}
@@ -35,6 +36,7 @@ tests/cases/compiler/genericSpecializations2.ts(12,9): error TS2368: Type parame
!!! error TS2416: Type '<string>(x: string) => string' is not assignable to type '<T>(x: T) => T'.
!!! error TS2416: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2416: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/compiler/genericSpecializations2.ts:2:9: This type parameter might need an `extends string` constraint.
~~~~~~
!!! error TS2368: Type parameter name cannot be 'string'.
}
@@ -18,10 +18,12 @@ tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Conversion
~~~~
!!! error TS2352: Conversion of type 'U' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
!!! error TS2352: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/compiler/genericTypeAssertions6.ts:1:11: This type parameter might need an `extends T` constraint.
y = <U>x;
~~~~
!!! error TS2352: Conversion of type 'T' to type 'U' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
!!! error TS2352: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/compiler/genericTypeAssertions6.ts:1:9: This type parameter might need an `extends U` constraint.
}
}
@@ -24,11 +24,11 @@ tests/cases/compiler/genericUnboundedTypeParamAssignability.ts(17,5): error TS23
f2(t); // error in strict, unbounded T doesn't satisfy the constraint
~
!!! error TS2345: Argument of type 'T' is not assignable to parameter of type '{}'.
!!! related TS2208 tests/cases/compiler/genericUnboundedTypeParamAssignability.ts:13:15: This type parameter probably needs an `extends object` constraint.
!!! related TS2208 tests/cases/compiler/genericUnboundedTypeParamAssignability.ts:13:15: This type parameter might need an `extends {}` constraint.
f3(t); // error in strict, unbounded T doesn't satisfy the constraint
~
!!! error TS2345: Argument of type 'T' is not assignable to parameter of type 'Record<string, any>'.
!!! related TS2208 tests/cases/compiler/genericUnboundedTypeParamAssignability.ts:13:15: This type parameter probably needs an `extends object` constraint.
!!! related TS2208 tests/cases/compiler/genericUnboundedTypeParamAssignability.ts:13:15: This type parameter might need an `extends Record<string, any>` constraint.
t.toString(); // error, for the same reason as f1()
~~~~~~~~
!!! error TS2339: Property 'toString' does not exist on type 'T'.
@@ -20,6 +20,7 @@ tests/cases/compiler/getAndSetNotIdenticalType2.ts(15,1): error TS2322: Type 'A<
~
!!! error TS2380: The return type of a 'get' accessor must be assignable to its 'set' accessor type
!!! error TS2380: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/compiler/getAndSetNotIdenticalType2.ts:3:9: This type parameter might need an `extends string` constraint.
return this.data;
}
set x(v: A<string>) {
@@ -22,6 +22,7 @@ tests/cases/compiler/implementGenericWithMismatchedTypes.ts(17,5): error TS2416:
!!! error TS2416: Type '(x: string) => number' is not assignable to type '(x: T) => T'.
!!! error TS2416: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2416: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/compiler/implementGenericWithMismatchedTypes.ts:7:9: This type parameter might need an `extends string` constraint.
return null;
}
}
@@ -27,6 +27,7 @@ tests/cases/compiler/indexSignatureAndMappedType.ts(16,5): error TS2322: Type '{
!!! error TS2322: Type 'Record<K, U>' is not assignable to type '{ [key: string]: T; }'.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/compiler/indexSignatureAndMappedType.ts:14:16: This type parameter might need an `extends T` constraint.
y = x; // Error
~
!!! error TS2322: Type '{ [key: string]: T; }' is not assignable to type 'Record<K, U>'.
@@ -210,6 +210,7 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(153,40): error TS2322:
type B<T> = string extends T ? { [P in T]: void; } : T; // Error
~
!!! error TS2322: Type 'T' is not assignable to type 'string | number | symbol'.
!!! related TS2208 tests/cases/conformance/types/conditional/inferTypes1.ts:153:8: This type parameter might need an `extends string | number | symbol` constraint.
// Repro from #22302
@@ -83,10 +83,12 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBa
!!! error TS2430: Interface 'Derived4<T>' incorrectly extends interface 'Base1<number>'.
!!! error TS2430: The types of 'x.a' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts:54:24: This type parameter might need an `extends number` constraint.
~~~~~~~~
!!! error TS2430: Interface 'Derived4<T>' incorrectly extends interface 'Base2<number>'.
!!! error TS2430: The types of 'x.b' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts:54:24: This type parameter might need an `extends number` constraint.
x: {
a: T; b: T;
}
@@ -97,10 +99,12 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBa
!!! error TS2430: Interface 'Derived5<T>' incorrectly extends interface 'Base1<T>'.
!!! error TS2430: Types of property 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type '{ a: T; }'.
!!! related TS2208 tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts:60:24: This type parameter might need an `extends { a: T; }` constraint.
~~~~~~~~
!!! error TS2430: Interface 'Derived5<T>' incorrectly extends interface 'Base2<T>'.
!!! error TS2430: Types of property 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type '{ b: T; }'.
!!! related TS2208 tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts:60:24: This type parameter might need an `extends { b: T; }` constraint.
x: T;
}
}
@@ -16,11 +16,13 @@ tests/cases/conformance/types/intersection/intersectionTypeInference.ts(6,5): er
!!! error TS2322: Type 'T' is not assignable to type 'T & U'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/intersection/intersectionTypeInference.ts:1:17: This type parameter might need an `extends U` constraint.
result = obj2; // Error
~~~~~~
!!! error TS2322: Type 'U' is not assignable to type 'T & U'.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/intersection/intersectionTypeInference.ts:1:20: This type parameter might need an `extends T` constraint.
return result;
}
@@ -49,6 +49,7 @@ tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts(22,5):
x = a;
~
!!! error TS2322: Type 'T' is not assignable to type 'void'.
!!! related TS2208 tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts:19:12: This type parameter might need an `extends void` constraint.
}
x = f;
~
@@ -40,4 +40,5 @@ tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(21,5): e
e = a;
~
!!! error TS2322: Type 'T' is not assignable to type 'E'.
!!! related TS2208 tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts:20:12: This type parameter might need an `extends E` constraint.
}
@@ -56,6 +56,7 @@ tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(26,5): error
x = a;
~
!!! error TS2322: Type 'T' is not assignable to type 'void'.
!!! related TS2208 tests/cases/conformance/types/primitives/void/invalidVoidValues.ts:23:12: This type parameter might need an `extends void` constraint.
}
x = f;
~
@@ -325,7 +325,7 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(318,5): error TS232
a = x;
~
!!! error TS2322: Type 'T' is not assignable to type '{}'.
!!! related TS2208 tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts:314:14: This type parameter probably needs an `extends object` constraint.
!!! related TS2208 tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts:314:14: This type parameter might need an `extends {}` constraint.
a = y;
~
!!! error TS2322: Type 'T[keyof T]' is not assignable to type '{}'.
@@ -259,6 +259,7 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts:99:13: This type parameter might need an `extends U` constraint.
tj = uj;
uj = tj; // error
@@ -266,6 +267,7 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error
!!! error TS2322: Type 'T[J]' is not assignable to type 'U[J]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts:99:13: This type parameter might need an `extends U` constraint.
tk = tj;
tj = tk; // error
@@ -280,6 +282,7 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[J]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts:99:13: This type parameter might need an `extends U` constraint.
}
// The constraint of 'keyof T' is 'keyof T'
@@ -19,6 +19,7 @@ tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts(24,9): e
let y: Modify<T> = val; // Error
~
!!! error TS2322: Type 'T' is not assignable to type 'Modify<T>'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts:10:14: This type parameter might need an `extends Modify<T>` constraint.
}
type FilterInclOpt<T> = { [P in keyof T as T[P] extends Function ? P : never]+?: T[P] };
@@ -31,12 +32,15 @@ tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts(24,9): e
let y: ModifyInclOpt<T> = val; // Ok
~
!!! error TS2322: Type 'T' is not assignable to type 'ModifyInclOpt<T>'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts:20:15: This type parameter might need an `extends ModifyInclOpt<T>` constraint.
let z: FilterExclOpt<T> = val; // Error
~
!!! error TS2322: Type 'T' is not assignable to type 'FilterExclOpt<T>'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts:20:15: This type parameter might need an `extends FilterExclOpt<T>` constraint.
let w: ModifyExclOpt<T> = val; // Error
~
!!! error TS2322: Type 'T' is not assignable to type 'ModifyExclOpt<T>'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts:20:15: This type parameter might need an `extends ModifyExclOpt<T>` constraint.
}
@@ -88,6 +88,7 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(152,17): error TS2339:
let y: Pick<Shape, T>; // Error
~
!!! error TS2344: Type 'T' does not satisfy the constraint 'keyof Shape'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:32:13: This type parameter might need an `extends keyof Shape` constraint.
}
function f2<T extends string | number>(x: T) {
@@ -240,6 +241,7 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(152,17): error TS2339:
pt: {[P in T]?: T[P]}, // note: should be in keyof T
~
!!! error TS2322: Type 'T' is not assignable to type 'string | number | symbol'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:134:11: This type parameter might need an `extends string | number | symbol` constraint.
~~~~
!!! error TS2536: Type 'P' cannot be used to index type 'T'.
};
@@ -89,6 +89,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts:9:13: This type parameter might need an `extends U` constraint.
}
function f4<T, U extends T, K extends keyof T>(x: T, y: U, k: K) {
@@ -98,6 +99,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts:14:13: This type parameter might need an `extends U` constraint.
}
function f5<T, U extends T>(x: T, y: U, k: keyof U) {
@@ -180,6 +182,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts:59:14: This type parameter might need an `extends U` constraint.
~~~~
!!! error TS2542: Index signature in type 'Readonly<U>' only permits reading.
}
@@ -191,6 +194,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts:64:14: This type parameter might need an `extends U` constraint.
~~~~
!!! error TS2542: Index signature in type 'Readonly<U>' only permits reading.
}
@@ -284,6 +288,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
!!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts:141:14: This type parameter might need an `extends U` constraint.
}
function f72<T, U extends T>(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) {
@@ -343,6 +348,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
!!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts:166:14: This type parameter might need an `extends U` constraint.
}
function f80<T>(t: T): Partial<T> {
@@ -66,6 +66,7 @@ tests/cases/conformance/types/mapped/mappedTypes6.ts(120,4): error TS2540: Canno
x = y; // Error
~
!!! error TS2322: Type 'T' is not assignable to type 'Required<T>'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypes6.ts:21:13: This type parameter might need an `extends Required<T>` constraint.
x = z; // Error
~
!!! error TS2322: Type 'Partial<T>' is not assignable to type 'Required<T>'.
@@ -108,6 +109,7 @@ tests/cases/conformance/types/mapped/mappedTypes6.ts(120,4): error TS2540: Canno
w = y; // Error
~
!!! error TS2322: Type 'T' is not assignable to type 'Denullified<T>'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypes6.ts:35:13: This type parameter might need an `extends Denullified<T>` constraint.
w = z; // Error
~
!!! error TS2322: Type 'Partial<T>' is not assignable to type 'Denullified<T>'.
@@ -116,6 +118,7 @@ tests/cases/conformance/types/mapped/mappedTypes6.ts(120,4): error TS2540: Canno
x = y; // Error
~
!!! error TS2322: Type 'T' is not assignable to type 'Required<T>'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypes6.ts:35:13: This type parameter might need an `extends Required<T>` constraint.
x = z; // Error
~
!!! error TS2322: Type 'Partial<T>' is not assignable to type 'Required<T>'.
@@ -33,7 +33,7 @@ tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts(25,11): error TS24
!!! error TS2430: Interface 'E1<T>' incorrectly extends interface 'Base'.
!!! error TS2430: Types of property 'foo' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type '{ [key: string]: any; }'.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts:25:14: This type parameter probably needs an `extends object` constraint.
!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts:25:14: This type parameter might need an `extends { [key: string]: any; }` constraint.
foo: T;
}
@@ -19,6 +19,7 @@ tests/cases/compiler/mismatchedGenericArguments1.ts(11,4): error TS2416: Propert
!!! error TS2416: Type '(x: string) => number' is not assignable to type '<T>(x: T) => T'.
!!! error TS2416: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2416: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/compiler/mismatchedGenericArguments1.ts:2:8: This type parameter might need an `extends string` constraint.
return null;
}
}
@@ -30,6 +31,7 @@ tests/cases/compiler/mismatchedGenericArguments1.ts(11,4): error TS2416: Propert
!!! error TS2416: Type '<U>(x: string) => number' is not assignable to type '<T>(x: T) => T'.
!!! error TS2416: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2416: Type 'T' is not assignable to type 'string'.
!!! related TS2208 tests/cases/compiler/mismatchedGenericArguments1.ts:2:8: This type parameter might need an `extends string` constraint.
return null;
}
}
@@ -15,8 +15,10 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts(11,9)
let a: object = x; // Error
~
!!! error TS2322: Type 'T' is not assignable to type 'object'.
!!! related TS2208 tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts:9:14: This type parameter might need an `extends object` constraint.
let b: U | object = x; // Error
~
!!! error TS2322: Type 'T' is not assignable to type 'object | U'.
!!! related TS2208 tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts:9:14: This type parameter might need an `extends object | U` constraint.
}
@@ -13,6 +13,7 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(34,14): erro
var o: object = t; // expect error
~
!!! error TS2322: Type 'T' is not assignable to type 'object'.
!!! related TS2208 tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts:1:18: This type parameter might need an `extends object` constraint.
}
var a = {};
var b = "42";
@@ -53,6 +53,7 @@ tests/cases/compiler/recursiveConditionalTypes.ts(169,5): error TS2322: Type 'nu
!!! error TS2322: Type '__Awaited<T>' is not assignable to type '__Awaited<U>'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/compiler/recursiveConditionalTypes.ts:18:14: This type parameter might need an `extends U` constraint.
ta = tx; // Error
~~
!!! error TS2322: Type 'T' is not assignable to type '__Awaited<T>'.
@@ -18,6 +18,7 @@ tests/cases/compiler/tile1.ts(24,7): error TS2322: Type 'C' is not assignable to
oninit?(vnode: Vnode<Attrs, State>): number;
~~~~~
!!! error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle<Attrs, State>'.
!!! related TS2208 tests/cases/compiler/tile1.ts:1:28: This type parameter might need an `extends Lifecycle<Attrs, State>` constraint.
[_: number]: any;
}
@@ -31,6 +32,7 @@ tests/cases/compiler/tile1.ts(24,7): error TS2322: Type 'C' is not assignable to
view(this: State, vnode: Vnode<Attrs, State>): number;
~~~~~
!!! error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle<Attrs, State>'.
!!! related TS2208 tests/cases/compiler/tile1.ts:10:28: This type parameter might need an `extends Lifecycle<Attrs, State>` constraint.
}
interface ClassComponent<A> extends Lifecycle<A, ClassComponent<A>> {
@@ -16,6 +16,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
!!! error TS2416: Property 'foo' in type 'D1<T, U>' is not assignable to the same property in base type 'C3<T>'.
!!! error TS2416: Type 'U' is not assignable to type 'T'.
!!! error TS2416: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts:7:13: This type parameter might need an `extends T` constraint.
}
function f1<T, U>(x: T, y: U) {
@@ -66,6 +66,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
!!! error TS2416: Property 'foo' in type 'D3<T, U>' is not assignable to the same property in base type 'C3<T>'.
!!! error TS2416: Type 'U' is not assignable to type 'T'.
!!! error TS2416: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts:17:23: This type parameter might need an `extends T` constraint.
}
class D4<T extends U, U> extends C3<U> {
@@ -126,6 +127,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
!!! error TS2416: Property 'foo' in type 'D11<T, U, V>' is not assignable to the same property in base type 'C3<T>'.
!!! error TS2416: Type 'V' is not assignable to type 'T'.
!!! error TS2416: 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts:65:37: This type parameter might need an `extends T` constraint.
}
class D12<T extends U, U extends V, V> extends C3<U> {
@@ -137,6 +139,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
!!! error TS2416: Property 'foo' in type 'D12<T, U, V>' is not assignable to the same property in base type 'C3<U>'.
!!! error TS2416: Type 'V' is not assignable to type 'U'.
!!! error TS2416: 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts:70:37: This type parameter might need an `extends U` constraint.
}
class D13<T extends U, U extends V, V> extends C3<V> {
@@ -72,6 +72,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
~~~
!!! error TS2416: Property 'foo' in type 'D3<T, U, V>' is not assignable to the same property in base type 'B1<Foo>'.
!!! error TS2416: Type 'V' is not assignable to type 'Foo'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts:45:40: This type parameter might need an `extends Foo` constraint.
}
class D4<T extends Foo, U extends Foo, V> extends B1<T> {
@@ -99,6 +100,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
!!! error TS2416: Property 'foo' in type 'D6<T, U, V>' is not assignable to the same property in base type 'B1<T>'.
!!! error TS2416: Type 'V' is not assignable to type 'T'.
!!! error TS2416: 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts:60:40: This type parameter might need an `extends T` constraint.
}
class D7<T extends Foo, U extends Foo, V> extends B1<U> {
@@ -126,4 +128,5 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
!!! error TS2416: Property 'foo' in type 'D9<T, U, V>' is not assignable to the same property in base type 'B1<U>'.
!!! error TS2416: Type 'V' is not assignable to type 'U'.
!!! error TS2416: 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts:75:40: This type parameter might need an `extends U` constraint.
}
@@ -79,6 +79,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts:12:13: This type parameter might need an `extends T` constraint.
a: new (x: T) => T[];
}
@@ -90,6 +91,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts:13:14: This type parameter might need an `extends T` constraint.
a2: new (x: T) => string[];
}
@@ -101,6 +103,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts:14:14: This type parameter might need an `extends T` constraint.
a3: new (x: T) => T;
}
@@ -112,6 +115,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts:15:14: This type parameter might need an `extends T` constraint.
a4: new <U>(x: T, y: U) => string;
}
@@ -124,6 +128,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'arg' and 'arg' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts:40:14: This type parameter might need an `extends T` constraint.
a5: new <U>(x: (arg: T) => U) => T;
}
@@ -137,6 +142,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of property 'foo' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts:18:15: This type parameter might need an `extends T` constraint.
a11: new <U>(x: { foo: T }, y: { foo: U; bar: U }) => Base;
}
@@ -216,6 +216,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'a()' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:100:18: This type parameter might need an `extends T` constraint.
a: () => T;
}
@@ -225,6 +226,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'a(...)' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:104:18: This type parameter might need an `extends T` constraint.
a: (x?: T) => T;
}
@@ -243,6 +245,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'a2(...)' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:113:18: This type parameter might need an `extends T` constraint.
a2: () => T;
}
@@ -254,6 +257,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:94:14: This type parameter might need an `extends T` constraint.
a2: (x?: T) => T
}
@@ -265,6 +269,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:94:14: This type parameter might need an `extends T` constraint.
a2: (x: T) => T;
}
@@ -275,6 +280,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'a3(...)' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:126:18: This type parameter might need an `extends T` constraint.
a3: () => T;
}
@@ -286,6 +292,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:95:14: This type parameter might need an `extends T` constraint.
a3: (x?: T) => T;
}
@@ -297,6 +304,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:95:14: This type parameter might need an `extends T` constraint.
a3: (x: T) => T;
}
@@ -315,6 +323,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'a4(...)' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:143:19: This type parameter might need an `extends T` constraint.
a4: () => T;
}
@@ -326,6 +335,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:96:14: This type parameter might need an `extends T` constraint.
a4: (x?: T, y?: T) => T;
}
@@ -337,6 +347,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:96:14: This type parameter might need an `extends T` constraint.
a4: (x: T) => T;
}
@@ -348,6 +359,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:96:14: This type parameter might need an `extends T` constraint.
a4: (x: T, y: T) => T;
}
@@ -358,6 +370,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'a5(...)' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:160:19: This type parameter might need an `extends T` constraint.
a5: () => T;
}
@@ -369,6 +382,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:97:14: This type parameter might need an `extends T` constraint.
a5: (x?: T, y?: T) => T;
}
@@ -380,6 +394,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:97:14: This type parameter might need an `extends T` constraint.
a5: (x: T) => T;
}
@@ -391,6 +406,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts:97:14: This type parameter might need an `extends T` constraint.
a5: (x: T, y: T) => T;
}
}
@@ -216,6 +216,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'new a()' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:100:18: This type parameter might need an `extends T` constraint.
a: new () => T;
}
@@ -225,6 +226,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'new a(...)' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:104:18: This type parameter might need an `extends T` constraint.
a: new (x?: T) => T;
}
@@ -243,6 +245,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'new a2(...)' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:113:18: This type parameter might need an `extends T` constraint.
a2: new () => T;
}
@@ -254,6 +257,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:94:18: This type parameter might need an `extends T` constraint.
a2: new (x?: T) => T
}
@@ -265,6 +269,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:94:18: This type parameter might need an `extends T` constraint.
a2: new (x: T) => T;
}
@@ -275,6 +280,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'new a3(...)' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:126:18: This type parameter might need an `extends T` constraint.
a3: new () => T;
}
@@ -286,6 +292,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:95:18: This type parameter might need an `extends T` constraint.
a3: new (x?: T) => T;
}
@@ -297,6 +304,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:95:18: This type parameter might need an `extends T` constraint.
a3: new (x: T) => T;
}
@@ -315,6 +323,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'new a4(...)' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:143:19: This type parameter might need an `extends T` constraint.
a4: new () => T;
}
@@ -326,6 +335,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:96:18: This type parameter might need an `extends T` constraint.
a4: new (x?: T, y?: T) => T;
}
@@ -337,6 +347,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:96:18: This type parameter might need an `extends T` constraint.
a4: new (x: T) => T;
}
@@ -348,6 +359,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:96:18: This type parameter might need an `extends T` constraint.
a4: new (x: T, y: T) => T;
}
@@ -358,6 +370,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: The types returned by 'new a5(...)' are incompatible between these types.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:160:19: This type parameter might need an `extends T` constraint.
a5: new () => T;
}
@@ -369,6 +382,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:97:18: This type parameter might need an `extends T` constraint.
a5: new (x?: T, y?: T) => T;
}
@@ -380,6 +394,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:97:18: This type parameter might need an `extends T` constraint.
a5: new (x: T) => T;
}
@@ -391,6 +406,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts:97:18: This type parameter might need an `extends T` constraint.
a5: new (x: T, y: T) => T;
}
}
@@ -52,6 +52,7 @@ tests/cases/conformance/types/literal/templateLiteralTypes1.ts(252,7): error TS2
z = x; // Error
~
!!! error TS2322: Type 'T' is not assignable to type '{ [P in keyof T & string as `p_${P}`]: T[P]; }'.
!!! related TS2208 tests/cases/conformance/types/literal/templateLiteralTypes1.ts:38:14: This type parameter might need an `extends { [P in keyof T & string as `p_${P}`]: T[P]; }` constraint.
}
function fa2<T, U extends T, A extends string, B extends A>(x: { [P in B as `p_${P}`]: T }, y: { [Q in A as `p_${Q}`]: U }) {
@@ -45,7 +45,7 @@ tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx(18,14): error TS2769: No o
~~~~~
!!! error TS2322: Type 'P' is not assignable to type 'IntrinsicAttributes & P'.
!!! error TS2322: Type 'P' is not assignable to type 'IntrinsicAttributes'.
!!! related TS2208 tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx:5:15: This type parameter probably needs an `extends object` constraint.
!!! related TS2208 tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx:5:15: This type parameter might need an `extends JSX.IntrinsicAttributes` constraint.
let q = <MyComponent {...wrappedProps} /> // should work
~~~~~~~~~~~
!!! error TS2769: No overload matches this call.
@@ -54,5 +54,7 @@ tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx(18,14): error TS2769: No o
!!! error TS2769: Type 'P' is not assignable to type 'IntrinsicAttributes'.
!!! error TS2769: Overload 2 of 2, '(props: P, context?: any): MyComponent', gave the following error.
!!! error TS2769: Type 'P' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComponent> & Readonly<{ children?: ReactNode; }> & Readonly<P>'.
!!! related TS2208 tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx:5:15: This type parameter probably needs an `extends object` constraint.
!!! related TS2208 tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx:5:15: This type parameter might need an `extends JSX.IntrinsicAttributes` constraint.
!!! related TS2208 tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx:5:15: This type parameter might need an `extends JSX.IntrinsicAttributes & JSX.IntrinsicClassAttributes<MyComponent> & Readonly<{ children?: React.ReactNode; }> & Readonly<P>` constraint.
!!! related TS2208 tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx:5:15: This type parameter might need an `extends JSX.IntrinsicAttributes & JSX.IntrinsicClassAttributes<MyComponent> & Readonly<{ children?: React.ReactNode; }> & Readonly<P>` constraint.
}
@@ -32,6 +32,8 @@ tests/cases/conformance/jsx/file.tsx(31,52): error TS2322: Type '(val: string) =
~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { prop: unknown; "ignore-prop": string; }'.
!!! error TS2322: Type 'T' is not assignable to type '{ prop: unknown; "ignore-prop": string; }'.
!!! related TS2208 tests/cases/conformance/jsx/file.tsx:12:14: This type parameter might need an `extends { prop: unknown; "ignore-prop": string; }` constraint.
!!! related TS2208 tests/cases/conformance/jsx/file.tsx:12:14: This type parameter might need an `extends JSX.IntrinsicAttributes & { prop: unknown; "ignore-prop": string; }` constraint.
}
declare function Link<U>(l: {func: (arg: U)=>void}): JSX.Element;
@@ -22,5 +22,6 @@ tests/cases/compiler/typeParameterArgumentEquivalence.ts(5,5): error TS2322: Typ
!!! error TS2322: Type '(item: number) => boolean' is not assignable to type '(item: T) => boolean'.
!!! error TS2322: Types of parameters 'item' and 'item' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/compiler/typeParameterArgumentEquivalence.ts:1:14: This type parameter might need an `extends number` constraint.
}
@@ -18,11 +18,13 @@ tests/cases/compiler/typeParameterArgumentEquivalence2.ts(5,5): error TS2322: Ty
!!! error TS2322: Types of parameters 'item' and 'item' are incompatible.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/compiler/typeParameterArgumentEquivalence2.ts:1:16: This type parameter might need an `extends T` constraint.
y = x; // Shound be an error
~
!!! error TS2322: Type '(item: U) => boolean' is not assignable to type '(item: T) => boolean'.
!!! error TS2322: Types of parameters 'item' and 'item' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/compiler/typeParameterArgumentEquivalence2.ts:1:14: This type parameter might need an `extends U` constraint.
}
@@ -18,5 +18,6 @@ tests/cases/compiler/typeParameterArgumentEquivalence3.ts(5,5): error TS2322: Ty
~
!!! error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => boolean'.
!!! error TS2322: Type 'T' is not assignable to type 'boolean'.
!!! related TS2208 tests/cases/compiler/typeParameterArgumentEquivalence3.ts:1:14: This type parameter might need an `extends boolean` constraint.
}
@@ -15,10 +15,12 @@ tests/cases/compiler/typeParameterArgumentEquivalence4.ts(5,5): error TS2322: Ty
!!! error TS2322: Type '(item: any) => T' is not assignable to type '(item: any) => U'.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/compiler/typeParameterArgumentEquivalence4.ts:1:14: This type parameter might need an `extends U` constraint.
y = x; // Shound be an error
~
!!! error TS2322: Type '(item: any) => U' is not assignable to type '(item: any) => T'.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/compiler/typeParameterArgumentEquivalence4.ts:1:16: This type parameter might need an `extends T` constraint.
}
@@ -18,11 +18,13 @@ tests/cases/compiler/typeParameterArgumentEquivalence5.ts(5,5): error TS2322: Ty
!!! error TS2322: Call signature return types '(item: any) => T' and '(item: any) => U' are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/compiler/typeParameterArgumentEquivalence5.ts:1:14: This type parameter might need an `extends U` constraint.
y = x; // Shound be an error
~
!!! error TS2322: Type '() => (item: any) => U' is not assignable to type '() => (item: any) => T'.
!!! error TS2322: Call signature return types '(item: any) => U' and '(item: any) => T' are incompatible.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/compiler/typeParameterArgumentEquivalence5.ts:1:16: This type parameter might need an `extends T` constraint.
}
@@ -12,8 +12,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara
~
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability.ts:3:17: This type parameter might need an `extends T` constraint.
u = t; // error
~
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability.ts:3:14: This type parameter might need an `extends U` constraint.
}
@@ -53,6 +53,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara
~
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts:3:14: This type parameter might need an `extends U` constraint.
}
function foo2<T extends U, U>(t: T, u: U) {
@@ -60,6 +61,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara
~
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts:8:28: This type parameter might need an `extends T` constraint.
u = t; // ok
}
@@ -74,12 +76,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara
~
!!! error TS2322: Type 'V' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts:13:41: This type parameter might need an `extends T` constraint.
v = t; // ok
u = v; // error
~
!!! error TS2322: Type 'V' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts:13:41: This type parameter might need an `extends U` constraint.
v = u; // ok
}
@@ -163,16 +167,19 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara
~
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts:63:28: This type parameter might need an `extends T` constraint.
t = v; // error
~
!!! error TS2322: Type 'V' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts:63:31: This type parameter might need an `extends T` constraint.
u = t; // ok
u = v; // error
~
!!! error TS2322: Type 'V' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts:63:31: This type parameter might need an `extends U` constraint.
v = t; // error
~
@@ -182,4 +189,5 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara
~
!!! error TS2322: Type 'U' is not assignable to type 'V'.
!!! error TS2322: 'V' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts:63:28: This type parameter might need an `extends V` constraint.
}
@@ -19,6 +19,7 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type
!!! error TS2322: Type 'Foo<U>' is not assignable to type 'Foo<T>'.
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/compiler/typeParameterAssignmentCompat1.ts:5:15: This type parameter might need an `extends T` constraint.
return x;
~~~~~~~~~
!!! error TS2322: Type 'Foo<T>' is not assignable to type 'Foo<U>'.
@@ -16,6 +16,7 @@ tests/cases/compiler/typeParameterDiamond2.ts(10,13): error TS2322: Type 'Bottom
~~~
!!! error TS2322: Type 'T | U' is not assignable to type 'Top'.
!!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'T | U'.
!!! related TS2208 tests/cases/compiler/typeParameterDiamond2.ts:2:43: This type parameter might need an `extends Top` constraint.
middle = bottom;
top = bottom;
~~~
@@ -19,11 +19,13 @@ tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom
~~~
!!! error TS2322: Type 'T | U' is not assignable to type 'Top'.
!!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'T | U'.
!!! related TS2208 tests/cases/compiler/typeParameterDiamond3.ts:2:28: This type parameter might need an `extends Top` constraint.
middle = bottom;
~~~~~~
!!! error TS2322: Type 'Bottom' is not assignable to type 'T | U'.
!!! error TS2322: Type 'Top | T | U' is not assignable to type 'T | U'.
!!! error TS2322: Type 'Top' is not assignable to type 'T | U'.
!!! related TS2208 tests/cases/compiler/typeParameterDiamond3.ts:1:21: This type parameter might need an `extends T | U` constraint.
top = bottom;
~~~
!!! error TS2322: Type 'Bottom' is not assignable to type 'Top'.
@@ -16,6 +16,7 @@ tests/cases/compiler/typeParameterDiamond4.ts(10,13): error TS2322: Type 'Bottom
~~~
!!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'.
!!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'Top | T | U'.
!!! related TS2208 tests/cases/compiler/typeParameterDiamond4.ts:2:28: This type parameter might need an `extends Top` constraint.
middle = bottom;
top = bottom;
~~~
@@ -9,6 +9,7 @@ tests/cases/compiler/typeParameterHasSelfAsConstraint.ts(2,5): error TS2322: Typ
return x;
~~~~~~~~~
!!! error TS2322: Type 'T' is not assignable to type 'number'.
!!! related TS2208 tests/cases/compiler/typeParameterHasSelfAsConstraint.ts:1:14: This type parameter might need an `extends number` constraint.
}
@@ -12,6 +12,7 @@ tests/cases/compiler/typeParametersShouldNotBeEqual.ts(5,5): error TS2322: Type
~
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/compiler/typeParametersShouldNotBeEqual.ts:1:16: This type parameter might need an `extends T` constraint.
x = z; // Error
~
!!! error TS2322: Type 'Object' is not assignable to type 'T'.
@@ -24,6 +24,7 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type
~
!!! error TS2322: Type 'V' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/compiler/typeParametersShouldNotBeEqual2.ts:1:45: This type parameter might need an `extends T` constraint.
z = x; // Error
~
!!! error TS2322: Type 'T' is not assignable to type 'V'.
@@ -32,6 +33,7 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type
~
!!! error TS2322: Type 'V' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'.
!!! related TS2208 tests/cases/compiler/typeParametersShouldNotBeEqual2.ts:1:45: This type parameter might need an `extends U` constraint.
z = y; // Error
~
!!! error TS2322: Type 'U' is not assignable to type 'V'.
@@ -133,10 +133,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTyp
~
!!! error TS2322: Type 'U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts:63:17: This type parameter might need an `extends T` constraint.
u = t; // error
~
!!! error TS2322: Type 'T' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts:63:14: This type parameter might need an `extends U` constraint.
var x : T | U;
x = t; // ok
x = u; // ok
@@ -145,9 +147,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTyp
~
!!! error TS2322: Type 'T | U' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T | U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts:63:17: This type parameter might need an `extends T` constraint.
u = x; // error T not assignable to U
~
!!! error TS2322: Type 'T | U' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T | U'.
!!! related TS2208 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts:63:14: This type parameter might need an `extends U` constraint.
}
@@ -250,7 +250,7 @@ tests/cases/conformance/types/unknown/unknownType1.ts(181,5): error TS2322: Type
let x: {} = t;
~
!!! error TS2322: Type 'T' is not assignable to type '{}'.
!!! related TS2208 tests/cases/conformance/types/unknown/unknownType1.ts:169:14: This type parameter probably needs an `extends object` constraint.
!!! related TS2208 tests/cases/conformance/types/unknown/unknownType1.ts:169:14: This type parameter might need an `extends {}` constraint.
let y: {} = u;
~
!!! error TS2322: Type 'U' is not assignable to type '{}'.
@@ -0,0 +1,17 @@
/// <reference path="fourslash.ts" />
// @Filename: file.ts
////function f<T>(x: T) {
//// const y: `${number}` = x/**/;
////}
goTo.marker("");
verify.codeFix({
index: 0,
description: "Add `extends` constraint.",
newFileContent: {
"/tests/cases/fourslash/file.ts":
`function f<T extends \`$\{number}\`>(x: T) {
const y: \`$\{number}\` = x;
}`
}
});
@@ -0,0 +1,21 @@
/// <reference path="fourslash.ts" />
// @Filename: file.ts
////interface Fn<T extends string> {
////}
////
////function m<T>(x: Fn<T/**/>) {
////}
goTo.marker("");
verify.codeFix({
index: 0,
description: "Add `extends` constraint.",
newFileContent: {
"/tests/cases/fourslash/file.ts":
`interface Fn<T extends string> {
}
function m<T extends string>(x: Fn<T>) {
}`
}
});