diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c2f5d4862f0f2..9daa089283dfa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18792,8 +18792,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)); + } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fc6f142c76ee4..bf3318fd895a7 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -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", diff --git a/src/services/codefixes/fixAddMissingConstraint.ts b/src/services/codefixes/fixAddMissingConstraint.ts new file mode 100644 index 0000000000000..cc622da055c1b --- /dev/null +++ b/src/services/codefixes/fixAddMissingConstraint.ts @@ -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; + } +} diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index cef6b9139698a..080c81ef6e602 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -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", diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt index 873bfc75d990f..4b707a808b38c 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt @@ -114,6 +114,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '(x: number) => number[]' is not assignable to type '(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: (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 '(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: (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 '(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: (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 '(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: (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: (x: T) => T[]; a15 = b15; // ok b15 = a15; // ok diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt index 9c4feaa193cf4..c410160366a8d 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt @@ -113,6 +113,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '(x: number) => string[]' is not assignable to type '(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: (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: (x: { a: T; b: T }) => number; a15 = b15a; @@ -223,6 +225,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '(x: T) => T[]' is not assignable to type '(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: (x: T) => string[]; @@ -232,6 +235,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '(x: T) => T[]' is not assignable to type '(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 '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt index 8085ccb2ca564..7e156f7a1a2f7 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt @@ -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: (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: (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: (x: (a: T) => T) => T[]; a17 = b17; // ok b17 = a17; // ok diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt index 31ffe46ed8d1d..3129b0b230a71 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt @@ -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: (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'. \ No newline at end of file +!!! 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. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt index 71893dd0f9bf4..288128515006b 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt @@ -114,6 +114,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'new (x: number) => number[]' is not assignable to type 'new (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 (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 (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 (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 (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 (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 (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 (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 (x: T) => T[]; a15 = b15; // ok b15 = a15; // ok diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt index 26730f1bf9ffc..4589f7f9c3995 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt @@ -129,6 +129,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'new (x: number) => string[]' is not assignable to type 'new (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 (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 (x: { a: T; b: T }) => number; a15 = b15a; // ok @@ -259,6 +261,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'new (x: T) => T[]' is not assignable to type 'new (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 (x: T) => string[]; @@ -268,6 +271,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'new (x: T) => T[]' is not assignable to type 'new (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 (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt index 4de654f24319c..65a5fd2e92c0b 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt @@ -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 (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 (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 (x: new (a: T) => T) => T[]; a17 = b17; // ok b17 = a17; // ok diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt index ba30460601063..a5289ca36c686 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt @@ -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 (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'. \ No newline at end of file +!!! 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. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt index 789a56e8985e2..692fd102e95bb 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt @@ -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. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt index f7f6643efa89f..e6abee1ecff81 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.errors.txt @@ -163,11 +163,13 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '() => T' is not assignable to type '() => 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'. !!! 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'. @@ -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'. !!! 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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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 '(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. } } diff --git a/tests/baselines/reference/assignmentStricterConstraints.errors.txt b/tests/baselines/reference/assignmentStricterConstraints.errors.txt index 0188afa20a896..012c05e281a15 100644 --- a/tests/baselines/reference/assignmentStricterConstraints.errors.txt +++ b/tests/baselines/reference/assignmentStricterConstraints.errors.txt @@ -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, "") \ No newline at end of file diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt index 868980a95a3ff..553dfe0af9428 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt @@ -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: (x: T) => T[]; // error } } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt index 38e69a84cb80b..ea8ce65119890 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt @@ -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: (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: (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: (x: { foo: T }, y: { foo: U; bar: U }) => Base; } diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt index 6926ee47722ce..a778f5b4b2a1d 100644 --- a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt @@ -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 diff --git a/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt b/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt index 029724d6fda48..7434f62aa4d42 100644 --- a/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt +++ b/tests/baselines/reference/commaOperatorOtherInvalidOperation.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypeVarianceBigArrayConstraintsPerformance.errors.txt b/tests/baselines/reference/conditionalTypeVarianceBigArrayConstraintsPerformance.errors.txt index 8f936562109f7..cb5751959d379 100644 --- a/tests/baselines/reference/conditionalTypeVarianceBigArrayConstraintsPerformance.errors.txt +++ b/tests/baselines/reference/conditionalTypeVarianceBigArrayConstraintsPerformance.errors.txt @@ -17,4 +17,5 @@ tests/cases/compiler/conditionalTypeVarianceBigArrayConstraintsPerformance.ts(9, !!! error TS2322: Type 'Stuff' is not assignable to type 'Stuff'. !!! 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. } \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypes1.errors.txt b/tests/baselines/reference/conditionalTypes1.errors.txt index f411c6270e8f8..e160259a6623a 100644 --- a/tests/baselines/reference/conditionalTypes1.errors.txt +++ b/tests/baselines/reference/conditionalTypes1.errors.txt @@ -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'. !!! 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(x: T, y: NonNullable) { diff --git a/tests/baselines/reference/conditionalTypes2.errors.txt b/tests/baselines/reference/conditionalTypes2.errors.txt index 673156cf50e0b..a96ab6ac3a5d0 100644 --- a/tests/baselines/reference/conditionalTypes2.errors.txt +++ b/tests/baselines/reference/conditionalTypes2.errors.txt @@ -55,6 +55,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. !!! 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: Contravariant, b: Contravariant) { @@ -63,6 +64,7 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. !!! 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 is a T that is known to be a Function diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt index 34d3fef5e64e8..21df07eb13ba1 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt @@ -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 (x: T) => T[]; // error } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt index 62a3cacb898d5..be322d328bcfc 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt @@ -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 (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 (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 (x: { foo: T }, y: { foo: U; bar: U }) => Base; } diff --git a/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt b/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt index 3d22f3fb320be..aad40f90ea465 100644 --- a/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt +++ b/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt @@ -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; } } diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt index 67733f98f4e93..7d2ca8c8e7a96 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt @@ -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(x: U, y: T = x) { } // ok function foo6(x: T, y: U, z: V = y) { } // error ~~~~~~~~ diff --git a/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt b/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt index 25915c23a88b7..cfb27a925bf89 100644 --- a/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt +++ b/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt @@ -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(y); ~~~~~~ !!! error TS2558: Expected 0 type arguments, but got 1. diff --git a/tests/baselines/reference/genericDefaultsErrors.errors.txt b/tests/baselines/reference/genericDefaultsErrors.errors.txt index ac765d8d7c1da..0666208437af6 100644 --- a/tests/baselines/reference/genericDefaultsErrors.errors.txt +++ b/tests/baselines/reference/genericDefaultsErrors.errors.txt @@ -39,6 +39,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(42,29): error TS2716: Type paramet declare function f05(): 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(): 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 { } // 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 { } // error ~~~~~~ !!! error TS2344: Type 'number' does not satisfy the constraint 'T'. diff --git a/tests/baselines/reference/genericSpecializations1.errors.txt b/tests/baselines/reference/genericSpecializations1.errors.txt index 83015cef25918..ee1f715293827 100644 --- a/tests/baselines/reference/genericSpecializations1.errors.txt +++ b/tests/baselines/reference/genericSpecializations1.errors.txt @@ -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 '(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 { @@ -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 '(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 { diff --git a/tests/baselines/reference/genericSpecializations2.errors.txt b/tests/baselines/reference/genericSpecializations2.errors.txt index 1088d7b895621..8e9f7cdb6c0b8 100644 --- a/tests/baselines/reference/genericSpecializations2.errors.txt +++ b/tests/baselines/reference/genericSpecializations2.errors.txt @@ -24,6 +24,7 @@ tests/cases/compiler/genericSpecializations2.ts(12,9): error TS2368: Type parame !!! error TS2416: Type '(x: string) => string' 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/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 '(x: string) => string' 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/genericSpecializations2.ts:2:9: This type parameter might need an `extends string` constraint. ~~~~~~ !!! error TS2368: Type parameter name cannot be 'string'. } diff --git a/tests/baselines/reference/genericTypeAssertions6.errors.txt b/tests/baselines/reference/genericTypeAssertions6.errors.txt index 84c68176da284..83cadc14d223e 100644 --- a/tests/baselines/reference/genericTypeAssertions6.errors.txt +++ b/tests/baselines/reference/genericTypeAssertions6.errors.txt @@ -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 = 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. } } diff --git a/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt b/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt index 6d7b87ebd3351..6604448bfa047 100644 --- a/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt +++ b/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt @@ -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'. -!!! 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` constraint. t.toString(); // error, for the same reason as f1() ~~~~~~~~ !!! error TS2339: Property 'toString' does not exist on type 'T'. diff --git a/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt b/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt index 77aec5a8f11ba..959090536b702 100644 --- a/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt +++ b/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt @@ -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) { diff --git a/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt b/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt index 51725f0502d91..428fe4725ad0d 100644 --- a/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt +++ b/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt @@ -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; } } diff --git a/tests/baselines/reference/indexSignatureAndMappedType.errors.txt b/tests/baselines/reference/indexSignatureAndMappedType.errors.txt index 6d09b876a4bbf..ca7d6cc70fb0c 100644 --- a/tests/baselines/reference/indexSignatureAndMappedType.errors.txt +++ b/tests/baselines/reference/indexSignatureAndMappedType.errors.txt @@ -27,6 +27,7 @@ tests/cases/compiler/indexSignatureAndMappedType.ts(16,5): error TS2322: Type '{ !!! error TS2322: Type 'Record' 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'. diff --git a/tests/baselines/reference/inferTypes1.errors.txt b/tests/baselines/reference/inferTypes1.errors.txt index 277f3e912d2a3..5e7c4bfebb5a4 100644 --- a/tests/baselines/reference/inferTypes1.errors.txt +++ b/tests/baselines/reference/inferTypes1.errors.txt @@ -210,6 +210,7 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(153,40): error TS2322: type B = 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 diff --git a/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt b/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt index c885a7859d4b2..30392f1ed6469 100644 --- a/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt +++ b/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt @@ -83,10 +83,12 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBa !!! error TS2430: Interface 'Derived4' incorrectly extends interface 'Base1'. !!! 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' incorrectly extends interface 'Base2'. !!! 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' incorrectly extends interface 'Base1'. !!! 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' incorrectly extends interface 'Base2'. !!! 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; } } \ No newline at end of file diff --git a/tests/baselines/reference/intersectionTypeInference.errors.txt b/tests/baselines/reference/intersectionTypeInference.errors.txt index 00ee06909cf89..947d7ca6fa230 100644 --- a/tests/baselines/reference/intersectionTypeInference.errors.txt +++ b/tests/baselines/reference/intersectionTypeInference.errors.txt @@ -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; } diff --git a/tests/baselines/reference/invalidAssignmentsToVoid.errors.txt b/tests/baselines/reference/invalidAssignmentsToVoid.errors.txt index 8e51c41425861..04641d51c68f0 100644 --- a/tests/baselines/reference/invalidAssignmentsToVoid.errors.txt +++ b/tests/baselines/reference/invalidAssignmentsToVoid.errors.txt @@ -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; ~ diff --git a/tests/baselines/reference/invalidEnumAssignments.errors.txt b/tests/baselines/reference/invalidEnumAssignments.errors.txt index e769a829c9789..901f7f5769dc8 100644 --- a/tests/baselines/reference/invalidEnumAssignments.errors.txt +++ b/tests/baselines/reference/invalidEnumAssignments.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/invalidVoidValues.errors.txt b/tests/baselines/reference/invalidVoidValues.errors.txt index b9b14cd688380..6bede7f146d59 100644 --- a/tests/baselines/reference/invalidVoidValues.errors.txt +++ b/tests/baselines/reference/invalidVoidValues.errors.txt @@ -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; ~ diff --git a/tests/baselines/reference/keyofAndIndexedAccess.errors.txt b/tests/baselines/reference/keyofAndIndexedAccess.errors.txt index 97bad1c12f5eb..8917c5e588822 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.errors.txt +++ b/tests/baselines/reference/keyofAndIndexedAccess.errors.txt @@ -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 '{}'. diff --git a/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt b/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt index b629598156274..b688b5794067a 100644 --- a/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt +++ b/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt @@ -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' diff --git a/tests/baselines/reference/mappedTypeAsClauseRelationships.errors.txt b/tests/baselines/reference/mappedTypeAsClauseRelationships.errors.txt index eee91fc97e37b..88563c0a0da56 100644 --- a/tests/baselines/reference/mappedTypeAsClauseRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeAsClauseRelationships.errors.txt @@ -19,6 +19,7 @@ tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts(24,9): e let y: Modify = val; // Error ~ !!! error TS2322: Type 'T' is not assignable to type 'Modify'. +!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts:10:14: This type parameter might need an `extends Modify` constraint. } type FilterInclOpt = { [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 = val; // Ok ~ !!! error TS2322: Type 'T' is not assignable to type 'ModifyInclOpt'. +!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts:20:15: This type parameter might need an `extends ModifyInclOpt` constraint. let z: FilterExclOpt = val; // Error ~ !!! error TS2322: Type 'T' is not assignable to type 'FilterExclOpt'. +!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts:20:15: This type parameter might need an `extends FilterExclOpt` constraint. let w: ModifyExclOpt = val; // Error ~ !!! error TS2322: Type 'T' is not assignable to type 'ModifyExclOpt'. +!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts:20:15: This type parameter might need an `extends ModifyExclOpt` constraint. } diff --git a/tests/baselines/reference/mappedTypeErrors.errors.txt b/tests/baselines/reference/mappedTypeErrors.errors.txt index 585287559bcc2..d599a93142793 100644 --- a/tests/baselines/reference/mappedTypeErrors.errors.txt +++ b/tests/baselines/reference/mappedTypeErrors.errors.txt @@ -88,6 +88,7 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(152,17): error TS2339: let y: Pick; // 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(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'. }; diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index 556fca80ccee4..33c20572d127c 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -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(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(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' 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' 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(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): Partial { diff --git a/tests/baselines/reference/mappedTypes6.errors.txt b/tests/baselines/reference/mappedTypes6.errors.txt index d0476d61a705b..965ee9f1f8b5a 100644 --- a/tests/baselines/reference/mappedTypes6.errors.txt +++ b/tests/baselines/reference/mappedTypes6.errors.txt @@ -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'. +!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypes6.ts:21:13: This type parameter might need an `extends Required` constraint. x = z; // Error ~ !!! error TS2322: Type 'Partial' is not assignable to type 'Required'. @@ -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'. +!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypes6.ts:35:13: This type parameter might need an `extends Denullified` constraint. w = z; // Error ~ !!! error TS2322: Type 'Partial' is not assignable to type 'Denullified'. @@ -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'. +!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypes6.ts:35:13: This type parameter might need an `extends Required` constraint. x = z; // Error ~ !!! error TS2322: Type 'Partial' is not assignable to type 'Required'. diff --git a/tests/baselines/reference/mappedTypesAndObjects.errors.txt b/tests/baselines/reference/mappedTypesAndObjects.errors.txt index c32fc58b370e7..b1f64e1ba611f 100644 --- a/tests/baselines/reference/mappedTypesAndObjects.errors.txt +++ b/tests/baselines/reference/mappedTypesAndObjects.errors.txt @@ -33,7 +33,7 @@ tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts(25,11): error TS24 !!! error TS2430: Interface 'E1' 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; } diff --git a/tests/baselines/reference/mismatchedGenericArguments1.errors.txt b/tests/baselines/reference/mismatchedGenericArguments1.errors.txt index 8c95aa78fb78a..b4d4dde8e1f1c 100644 --- a/tests/baselines/reference/mismatchedGenericArguments1.errors.txt +++ b/tests/baselines/reference/mismatchedGenericArguments1.errors.txt @@ -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 '(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 '(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/mismatchedGenericArguments1.ts:2:8: This type parameter might need an `extends string` constraint. return null; } } diff --git a/tests/baselines/reference/nonPrimitiveAndTypeVariables.errors.txt b/tests/baselines/reference/nonPrimitiveAndTypeVariables.errors.txt index c3e8acb3923ab..60045292a677c 100644 --- a/tests/baselines/reference/nonPrimitiveAndTypeVariables.errors.txt +++ b/tests/baselines/reference/nonPrimitiveAndTypeVariables.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt index 5cc7d3664b080..35372965554fd 100644 --- a/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt +++ b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt @@ -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"; diff --git a/tests/baselines/reference/recursiveConditionalTypes.errors.txt b/tests/baselines/reference/recursiveConditionalTypes.errors.txt index 3706310c55970..2e2d3a52564c9 100644 --- a/tests/baselines/reference/recursiveConditionalTypes.errors.txt +++ b/tests/baselines/reference/recursiveConditionalTypes.errors.txt @@ -53,6 +53,7 @@ tests/cases/compiler/recursiveConditionalTypes.ts(169,5): error TS2322: Type 'nu !!! error TS2322: Type '__Awaited' is not assignable to type '__Awaited'. !!! 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'. diff --git a/tests/baselines/reference/subclassThisTypeAssignable01.errors.txt b/tests/baselines/reference/subclassThisTypeAssignable01.errors.txt index be9404bf1fd7d..b6512f50238d5 100644 --- a/tests/baselines/reference/subclassThisTypeAssignable01.errors.txt +++ b/tests/baselines/reference/subclassThisTypeAssignable01.errors.txt @@ -18,6 +18,7 @@ tests/cases/compiler/tile1.ts(24,7): error TS2322: Type 'C' is not assignable to oninit?(vnode: Vnode): number; ~~~~~ !!! error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle'. +!!! related TS2208 tests/cases/compiler/tile1.ts:1:28: This type parameter might need an `extends Lifecycle` 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): number; ~~~~~ !!! error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle'. +!!! related TS2208 tests/cases/compiler/tile1.ts:10:28: This type parameter might need an `extends Lifecycle` constraint. } interface ClassComponent extends Lifecycle> { diff --git a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt index 9687182836167..b01153361b1df 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt @@ -16,6 +16,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D1' is not assignable to the same property in base type 'C3'. !!! 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(x: T, y: U) { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt index 47d37449c0925..7f4b39ae80698 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt @@ -66,6 +66,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'C3'. !!! 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 extends C3 { @@ -126,6 +127,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D11' is not assignable to the same property in base type 'C3'. !!! 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 extends C3 { @@ -137,6 +139,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D12' is not assignable to the same property in base type 'C3'. !!! 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 extends C3 { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index ece15e0e45196..463b3e33b1c5d 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt @@ -72,6 +72,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'B1'. !!! 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 extends B1 { @@ -99,6 +100,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'B1'. !!! 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 extends B1 { @@ -126,4 +128,5 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D9' is not assignable to the same property in base type 'B1'. !!! 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. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt b/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt index adb6a36c18b29..4b8030690c2e4 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt +++ b/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt @@ -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 (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 (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 (x: { foo: T }, y: { foo: U; bar: U }) => Base; } diff --git a/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt b/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt index 26e3294389850..b9d5dc7ae8b1e 100644 --- a/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt +++ b/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt @@ -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; } } diff --git a/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt b/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt index 7c87bfbc104a8..3324928c05c00 100644 --- a/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt +++ b/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt @@ -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; } } diff --git a/tests/baselines/reference/templateLiteralTypes1.errors.txt b/tests/baselines/reference/templateLiteralTypes1.errors.txt index 384125f3380bc..8de256dde60bd 100644 --- a/tests/baselines/reference/templateLiteralTypes1.errors.txt +++ b/tests/baselines/reference/templateLiteralTypes1.errors.txt @@ -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(x: { [P in B as `p_${P}`]: T }, y: { [Q in A as `p_${Q}`]: U }) { diff --git a/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt b/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt index a967c92e555ac..a735947e23fed 100644 --- a/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt +++ b/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt @@ -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 = // 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 & Readonly<{ children?: ReactNode; }> & Readonly

'. -!!! 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 & Readonly<{ children?: React.ReactNode; }> & Readonly

` constraint. +!!! related TS2208 tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx:5:15: This type parameter might need an `extends JSX.IntrinsicAttributes & JSX.IntrinsicClassAttributes & Readonly<{ children?: React.ReactNode; }> & Readonly

` constraint. } \ No newline at end of file diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.errors.txt b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.errors.txt index 4f59b5a4e89c0..f3ce91abd95ea 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.errors.txt +++ b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.errors.txt @@ -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(l: {func: (arg: U)=>void}): JSX.Element; diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt index 67c6cf36d9bb8..d47316a8e94a0 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt index 3cc1050ebe239..dfdc795c537fd 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence2.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt index 71075f7e40b37..4fd82dc215aef 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence3.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt index 4fa985ad6dc48..8adb5f168a207 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence4.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt b/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt index 6b3f2c7b6987e..84efd8fde35ca 100644 --- a/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt +++ b/tests/baselines/reference/typeParameterArgumentEquivalence5.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignability.errors.txt b/tests/baselines/reference/typeParameterAssignability.errors.txt index bf517963221d0..a64d041bd3e35 100644 --- a/tests/baselines/reference/typeParameterAssignability.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignability2.errors.txt b/tests/baselines/reference/typeParameterAssignability2.errors.txt index e95c4b94f4eb4..21c7c0aa9a9c1 100644 --- a/tests/baselines/reference/typeParameterAssignability2.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability2.errors.txt @@ -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: 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. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt index f2f8bf07f2799..445b77852b9a5 100644 --- a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt +++ b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt @@ -19,6 +19,7 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. !!! 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' is not assignable to type 'Foo'. diff --git a/tests/baselines/reference/typeParameterDiamond2.errors.txt b/tests/baselines/reference/typeParameterDiamond2.errors.txt index e408519b06e86..e320690786318 100644 --- a/tests/baselines/reference/typeParameterDiamond2.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond2.errors.txt @@ -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; ~~~ diff --git a/tests/baselines/reference/typeParameterDiamond3.errors.txt b/tests/baselines/reference/typeParameterDiamond3.errors.txt index 87e8d67545544..9e047e7c78c7e 100644 --- a/tests/baselines/reference/typeParameterDiamond3.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond3.errors.txt @@ -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'. diff --git a/tests/baselines/reference/typeParameterDiamond4.errors.txt b/tests/baselines/reference/typeParameterDiamond4.errors.txt index 147b3f1a183cd..4a75989c51987 100644 --- a/tests/baselines/reference/typeParameterDiamond4.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond4.errors.txt @@ -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; ~~~ diff --git a/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt b/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt index 01cfff63e5f6b..6d07df51c5a6c 100644 --- a/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt +++ b/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt index b2a497ab682b5..e21eec50a8cd8 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt @@ -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'. diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt index 8016f5209a669..cf12f6bc2c535 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt @@ -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'. diff --git a/tests/baselines/reference/unionTypesAssignability.errors.txt b/tests/baselines/reference/unionTypesAssignability.errors.txt index 365a95f971ad9..c14da234a8fc4 100644 --- a/tests/baselines/reference/unionTypesAssignability.errors.txt +++ b/tests/baselines/reference/unionTypesAssignability.errors.txt @@ -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. } \ No newline at end of file diff --git a/tests/baselines/reference/unknownType1.errors.txt b/tests/baselines/reference/unknownType1.errors.txt index a827753e5a25f..3f441448067f0 100644 --- a/tests/baselines/reference/unknownType1.errors.txt +++ b/tests/baselines/reference/unknownType1.errors.txt @@ -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 '{}'. diff --git a/tests/cases/fourslash/quickfixAddMissingConstraint.ts b/tests/cases/fourslash/quickfixAddMissingConstraint.ts new file mode 100644 index 0000000000000..5cb8d98c3ba17 --- /dev/null +++ b/tests/cases/fourslash/quickfixAddMissingConstraint.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: file.ts +////function f(x: T) { +//// const y: `${number}` = x/**/; +////} +goTo.marker(""); +verify.codeFix({ + index: 0, + description: "Add `extends` constraint.", + newFileContent: { + "/tests/cases/fourslash/file.ts": +`function f(x: T) { + const y: \`$\{number}\` = x; +}` + } +}); diff --git a/tests/cases/fourslash/quickfixAddMissingConstraint2.ts b/tests/cases/fourslash/quickfixAddMissingConstraint2.ts new file mode 100644 index 0000000000000..8681b09b6c905 --- /dev/null +++ b/tests/cases/fourslash/quickfixAddMissingConstraint2.ts @@ -0,0 +1,21 @@ +/// + +// @Filename: file.ts +////interface Fn { +////} +//// +////function m(x: Fn) { +////} +goTo.marker(""); +verify.codeFix({ + index: 0, + description: "Add `extends` constraint.", + newFileContent: { + "/tests/cases/fourslash/file.ts": +`interface Fn { +} + +function m(x: Fn) { +}` + } +});