From fdd8a52240e1576cc349d2ff73eeb44264f1d862 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 9 Jan 2018 10:20:07 -0800 Subject: [PATCH] Offer per-member diagnostics for incorrectly implemented inherited members (#21036) * Offer per-member diagnostics for incorrectly implemented inherited members on classes * Revise error message, make containingChain a thunk * Fix typo in comment --- src/compiler/checker.ts | 66 ++++- src/compiler/diagnosticMessages.json | 4 + .../abstractPropertyNegative.errors.txt | 36 ++- .../apparentTypeSubtyping.errors.txt | 16 +- .../apparentTypeSupertype.errors.txt | 20 +- ...baseClassImprovedMismatchErrors.errors.txt | 73 ++++++ .../baseClassImprovedMismatchErrors.js | 57 +++++ .../baseClassImprovedMismatchErrors.symbols | 42 +++ .../baseClassImprovedMismatchErrors.types | 47 ++++ .../classIsSubtypeOfBaseType.errors.txt | 16 +- ...ctionOverridesBaseClassAccessor.errors.txt | 12 +- ...tructuringParameterDeclaration2.errors.txt | 24 +- .../reference/elaboratedErrors.errors.txt | 12 +- .../reference/genericImplements.errors.txt | 16 +- .../genericSpecializations1.errors.txt | 40 ++- .../genericSpecializations2.errors.txt | 40 ++- .../genericSpecializations3.errors.txt | 20 +- ...cTypeWithNonGenericBaseMisMatch.errors.txt | 20 +- ...ementGenericWithMismatchedTypes.errors.txt | 36 ++- ...mplementsIncorrectlyNoAssertion.errors.txt | 14 +- .../reference/incompatibleTypes.errors.txt | 62 ++--- .../reference/inheritance.errors.txt | 12 +- ...eMemberAccessorOverridingMethod.errors.txt | 19 +- ...nceMemberFuncOverridingAccessor.errors.txt | 12 +- .../instanceSubtypeCheck2.errors.txt | 12 +- .../interfaceDeclaration3.errors.txt | 24 +- ...terfaceExtendsClassWithPrivate2.errors.txt | 17 +- ...ExtendsObjectIntersectionErrors.errors.txt | 62 ++--- .../interfaceImplementation7.errors.txt | 16 +- .../mismatchedGenericArguments1.errors.txt | 40 ++- .../reference/multipleInheritance.errors.txt | 12 +- .../requiredInitializedParameter2.errors.txt | 12 +- .../subtypesOfTypeParameter.errors.txt | 12 +- ...sOfTypeParameterWithConstraints.errors.txt | 140 +++++----- ...OfTypeParameterWithConstraints4.errors.txt | 68 +++-- ...rameterWithRecursiveConstraints.errors.txt | 240 ++++++++---------- .../subtypingWithObjectMembers.errors.txt | 72 +++--- .../baseClassImprovedMismatchErrors.ts | 18 ++ tests/cases/fourslash/incompatibleOverride.ts | 4 +- .../squiggleIllegalSubclassOverride.ts | 4 +- 40 files changed, 799 insertions(+), 670 deletions(-) create mode 100644 tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt create mode 100644 tests/baselines/reference/baseClassImprovedMismatchErrors.js create mode 100644 tests/baselines/reference/baseClassImprovedMismatchErrors.symbols create mode 100644 tests/baselines/reference/baseClassImprovedMismatchErrors.types create mode 100644 tests/cases/compiler/baseClassImprovedMismatchErrors.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ca5ce39cef7..d153eee3034 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9169,7 +9169,7 @@ namespace ts { return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); } - function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { + function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); } @@ -9177,7 +9177,7 @@ namespace ts { * This is *not* a bi-directional relationship. * If one needs to check both directions for comparability, use a second call to this function or 'isTypeComparableTo'. */ - function checkTypeComparableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean { + function checkTypeComparableTo(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } @@ -9511,7 +9511,7 @@ namespace ts { relation: Map, errorNode: Node, headMessage?: DiagnosticMessage, - containingMessageChain?: DiagnosticMessageChain): boolean { + containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { let errorInfo: DiagnosticMessageChain; let maybeKeys: string[]; @@ -9531,7 +9531,10 @@ namespace ts { } else if (errorInfo) { if (containingMessageChain) { - errorInfo = concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); + const chain = containingMessageChain(); + if (chain) { + errorInfo = concatenateDiagnosticMessageChains(chain, errorInfo); + } } diagnostics.add(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); @@ -16675,7 +16678,7 @@ namespace ts { const constraint = getConstraintOfTypeParameter(typeParameters[i]); if (!constraint) continue; - const errorInfo = reportErrors && headMessage && chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + const errorInfo = reportErrors && headMessage && (() => chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Type_0_does_not_satisfy_the_constraint_1)); const typeArgumentHeadMessage = headMessage || Diagnostics.Type_0_does_not_satisfy_the_constraint_1; if (!mapper) { mapper = createTypeMapper(typeParameters, typeArgumentTypes); @@ -19697,7 +19700,7 @@ namespace ts { Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - const leadingError = chainDiagnosticMessages(/*details*/ undefined, Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); + const leadingError = () => chainDiagnosticMessages(/*details*/ undefined, Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), node.type, @@ -20984,7 +20987,7 @@ namespace ts { expectedReturnType, node, headMessage, - errorInfo); + () => errorInfo); } /** @@ -22907,7 +22910,10 @@ namespace ts { } } } - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); + const baseWithThis = getTypeWithThisArgument(baseType, type.thisType); + if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) { + issueMemberSpecificError(node, typeWithThis, baseWithThis, Diagnostics.Class_0_incorrectly_extends_base_class_1); + } checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseConstructorType.flags & TypeFlags.TypeVariable && !isMixinConstructorType(staticType)) { @@ -22939,12 +22945,13 @@ namespace ts { const t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { if (isValidBaseType(t)) { - checkTypeAssignableTo(typeWithThis, - getTypeWithThisArgument(t, type.thisType), - node.name || node, - t.symbol && t.symbol.flags & SymbolFlags.Class ? - Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : - Diagnostics.Class_0_incorrectly_implements_interface_1); + const genericDiag = t.symbol && t.symbol.flags & SymbolFlags.Class ? + Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : + Diagnostics.Class_0_incorrectly_implements_interface_1; + const baseWithThis = getTypeWithThisArgument(t, type.thisType); + if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) { + issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag); + } } else { error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface); @@ -22961,6 +22968,37 @@ namespace ts { } } + function issueMemberSpecificError(node: ClassLikeDeclaration, typeWithThis: Type, baseWithThis: Type, broadDiag: DiagnosticMessage) { + // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible + let issuedMemberError = false; + for (const member of node.members) { + if (hasStaticModifier(member)) { + continue; + } + const declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); + if (declaredProp) { + const prop = getPropertyOfType(typeWithThis, declaredProp.escapedName); + const baseProp = getPropertyOfType(baseWithThis, declaredProp.escapedName); + if (prop && baseProp) { + const rootChain = () => chainDiagnosticMessages( + /*details*/ undefined, + Diagnostics.Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2, + unescapeLeadingUnderscores(declaredProp.escapedName), + typeToString(typeWithThis), + typeToString(getTypeOfSymbol(baseProp)) + ); + if (!checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(baseProp), member.name || member, /*message*/ undefined, rootChain)) { + issuedMemberError = true; + } + } + } + } + if (!issuedMemberError) { + // check again with diagnostics to generate a less-specific error + checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag); + } + } + function checkBaseTypeAccessibility(type: Type, node: ExpressionWithTypeArguments) { const signatures = getSignaturesOfType(type, SignatureKind.Construct); if (signatures.length) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3fc415b37a0..4a705ce97fe 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1404,6 +1404,10 @@ "category": "Error", "code": 2415 }, + "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'.": { + "category": "Error", + "code": 2416 + }, "Class static side '{0}' incorrectly extends base class static side '{1}'.": { "category": "Error", "code": 2417 diff --git a/tests/baselines/reference/abstractPropertyNegative.errors.txt b/tests/baselines/reference/abstractPropertyNegative.errors.txt index 314ab842ded..6e4cae81db9 100644 --- a/tests/baselines/reference/abstractPropertyNegative.errors.txt +++ b/tests/baselines/reference/abstractPropertyNegative.errors.txt @@ -7,15 +7,12 @@ tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstra tests/cases/compiler/abstractPropertyNegative.ts(15,5): error TS1244: Abstract methods can only appear within an abstract class. tests/cases/compiler/abstractPropertyNegative.ts(16,37): error TS1005: '{' expected. tests/cases/compiler/abstractPropertyNegative.ts(19,3): error TS2540: Cannot assign to 'ro' because it is a constant or a read-only property. -tests/cases/compiler/abstractPropertyNegative.ts(24,7): error TS2415: Class 'WrongTypePropertyImpl' incorrectly extends base class 'WrongTypeProperty'. - Types of property 'num' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/compiler/abstractPropertyNegative.ts(30,7): error TS2415: Class 'WrongTypeAccessorImpl' incorrectly extends base class 'WrongTypeAccessor'. - Types of property 'num' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/compiler/abstractPropertyNegative.ts(33,7): error TS2415: Class 'WrongTypeAccessorImpl2' incorrectly extends base class 'WrongTypeAccessor'. - Types of property 'num' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/compiler/abstractPropertyNegative.ts(25,5): error TS2416: Property 'num' in type 'WrongTypePropertyImpl' is not assignable to the same property in base type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/compiler/abstractPropertyNegative.ts(31,9): error TS2416: Property 'num' in type 'WrongTypeAccessorImpl' is not assignable to the same property in base type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/compiler/abstractPropertyNegative.ts(34,5): error TS2416: Property 'num' in type 'WrongTypeAccessorImpl2' is not assignable to the same property in base type 'number'. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/abstractPropertyNegative.ts(38,18): error TS2676: Accessors must both be abstract or non-abstract. tests/cases/compiler/abstractPropertyNegative.ts(39,9): error TS2676: Accessors must both be abstract or non-abstract. tests/cases/compiler/abstractPropertyNegative.ts(40,9): error TS2676: Accessors must both be abstract or non-abstract. @@ -65,28 +62,25 @@ tests/cases/compiler/abstractPropertyNegative.ts(41,18): error TS2676: Accessors abstract num: number; } class WrongTypePropertyImpl extends WrongTypeProperty { - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2415: Class 'WrongTypePropertyImpl' incorrectly extends base class 'WrongTypeProperty'. -!!! error TS2415: Types of property 'num' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'number'. num = "nope, wrong"; + ~~~ +!!! error TS2416: Property 'num' in type 'WrongTypePropertyImpl' is not assignable to the same property in base type 'number'. +!!! error TS2416: Type 'string' is not assignable to type 'number'. } abstract class WrongTypeAccessor { abstract get num(): number; } class WrongTypeAccessorImpl extends WrongTypeAccessor { - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2415: Class 'WrongTypeAccessorImpl' incorrectly extends base class 'WrongTypeAccessor'. -!!! error TS2415: Types of property 'num' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'number'. get num() { return "nope, wrong"; } + ~~~ +!!! error TS2416: Property 'num' in type 'WrongTypeAccessorImpl' is not assignable to the same property in base type 'number'. +!!! error TS2416: Type 'string' is not assignable to type 'number'. } class WrongTypeAccessorImpl2 extends WrongTypeAccessor { - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2415: Class 'WrongTypeAccessorImpl2' incorrectly extends base class 'WrongTypeAccessor'. -!!! error TS2415: Types of property 'num' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'number'. num = "nope, wrong"; + ~~~ +!!! error TS2416: Property 'num' in type 'WrongTypeAccessorImpl2' is not assignable to the same property in base type 'number'. +!!! error TS2416: Type 'string' is not assignable to type 'number'. } abstract class AbstractAccessorMismatch { diff --git a/tests/baselines/reference/apparentTypeSubtyping.errors.txt b/tests/baselines/reference/apparentTypeSubtyping.errors.txt index 01fffeb3824..cde65657778 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.errors.txt +++ b/tests/baselines/reference/apparentTypeSubtyping.errors.txt @@ -1,7 +1,6 @@ -tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(9,7): error TS2415: Class 'Derived' incorrectly extends base class 'Base'. - Types of property 'x' are incompatible. - Type 'String' is not assignable to type 'string'. - 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. +tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(10,5): error TS2416: Property 'x' in type 'Derived' is not assignable to the same property in base type 'string'. + Type 'String' is not assignable to type 'string'. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts (1 errors) ==== @@ -14,12 +13,11 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi // is String (S) a subtype of U extends String (T)? Would only be true if we used the apparent type of U (T) class Derived extends Base { // error - ~~~~~~~ -!!! error TS2415: Class 'Derived' incorrectly extends base class 'Base'. -!!! error TS2415: Types of property 'x' are incompatible. -!!! error TS2415: Type 'String' is not assignable to type 'string'. -!!! error TS2415: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. x: String; + ~ +!!! error TS2416: Property 'x' in type 'Derived' is not assignable to the same property in base type 'string'. +!!! error TS2416: Type 'String' is not assignable to type 'string'. +!!! error TS2416: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. } class Base2 { diff --git a/tests/baselines/reference/apparentTypeSupertype.errors.txt b/tests/baselines/reference/apparentTypeSupertype.errors.txt index c7610a80f2f..066d0be2710 100644 --- a/tests/baselines/reference/apparentTypeSupertype.errors.txt +++ b/tests/baselines/reference/apparentTypeSupertype.errors.txt @@ -1,8 +1,7 @@ -tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts(9,7): error TS2415: Class 'Derived' incorrectly extends base class 'Base'. - Types of property 'x' are incompatible. - Type 'U' is not assignable to type 'string'. - Type 'String' is not assignable to type 'string'. - 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. +tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts(10,5): error TS2416: Property 'x' in type 'Derived' is not assignable to the same property in base type 'string'. + Type 'U' is not assignable to type 'string'. + Type 'String' is not assignable to type 'string'. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (1 errors) ==== @@ -15,11 +14,10 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty // is String (S) a subtype of U extends String (T)? Would only be true if we used the apparent type of U (T) class Derived extends Base { // error - ~~~~~~~ -!!! error TS2415: Class 'Derived' incorrectly extends base class 'Base'. -!!! error TS2415: Types of property 'x' are incompatible. -!!! error TS2415: Type 'U' is not assignable to type 'string'. -!!! error TS2415: Type 'String' is not assignable to type 'string'. -!!! error TS2415: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. x: U; + ~ +!!! error TS2416: Property 'x' in type 'Derived' is not assignable to the same property in base type 'string'. +!!! error TS2416: Type 'U' is not assignable to type 'string'. +!!! error TS2416: Type 'String' is not assignable to type 'string'. +!!! error TS2416: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. } \ No newline at end of file diff --git a/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt b/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt new file mode 100644 index 00000000000..585c929d9a4 --- /dev/null +++ b/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt @@ -0,0 +1,73 @@ +tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2416: Property 'n' in type 'Derived' is not assignable to the same property in base type 'string | Base'. + Type 'string | Derived' is not assignable to type 'string | Base'. + Type 'Derived' is not assignable to type 'string | Base'. + Type 'Derived' is not assignable to type 'Base'. + Types of property 'n' are incompatible. + Type 'string | Derived' is not assignable to type 'string | Base'. + Type 'Derived' is not assignable to type 'string | Base'. + Type 'Derived' is not assignable to type 'Base'. +tests/cases/compiler/baseClassImprovedMismatchErrors.ts(9,5): error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type '() => number'. + Type '() => string | number' is not assignable to type '() => number'. + Type 'string | number' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/compiler/baseClassImprovedMismatchErrors.ts(14,5): error TS2416: Property 'n' in type 'DerivedInterface' is not assignable to the same property in base type 'string | Base'. + Type 'string | DerivedInterface' is not assignable to type 'string | Base'. + Type 'DerivedInterface' is not assignable to type 'string | Base'. + Type 'DerivedInterface' is not assignable to type 'Base'. + Types of property 'n' are incompatible. + Type 'string | DerivedInterface' is not assignable to type 'string | Base'. + Type 'DerivedInterface' is not assignable to type 'string | Base'. + Type 'DerivedInterface' is not assignable to type 'Base'. +tests/cases/compiler/baseClassImprovedMismatchErrors.ts(15,5): error TS2416: Property 'fn' in type 'DerivedInterface' is not assignable to the same property in base type '() => number'. + Type '() => string | number' is not assignable to type '() => number'. + Type 'string | number' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. + + +==== tests/cases/compiler/baseClassImprovedMismatchErrors.ts (4 errors) ==== + class Base { + n: Base | string; + fn() { + return 10; + } + } + class Derived extends Base { + n: Derived | string; + ~ +!!! error TS2416: Property 'n' in type 'Derived' is not assignable to the same property in base type 'string | Base'. +!!! error TS2416: Type 'string | Derived' is not assignable to type 'string | Base'. +!!! error TS2416: Type 'Derived' is not assignable to type 'string | Base'. +!!! error TS2416: Type 'Derived' is not assignable to type 'Base'. +!!! error TS2416: Types of property 'n' are incompatible. +!!! error TS2416: Type 'string | Derived' is not assignable to type 'string | Base'. +!!! error TS2416: Type 'Derived' is not assignable to type 'string | Base'. +!!! error TS2416: Type 'Derived' is not assignable to type 'Base'. + fn() { + ~~ +!!! error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type '() => number'. +!!! error TS2416: Type '() => string | number' is not assignable to type '() => number'. +!!! error TS2416: Type 'string | number' is not assignable to type 'number'. +!!! error TS2416: Type 'string' is not assignable to type 'number'. + return 10 as number | string; + } + } + class DerivedInterface implements Base { + n: DerivedInterface | string; + ~ +!!! error TS2416: Property 'n' in type 'DerivedInterface' is not assignable to the same property in base type 'string | Base'. +!!! error TS2416: Type 'string | DerivedInterface' is not assignable to type 'string | Base'. +!!! error TS2416: Type 'DerivedInterface' is not assignable to type 'string | Base'. +!!! error TS2416: Type 'DerivedInterface' is not assignable to type 'Base'. +!!! error TS2416: Types of property 'n' are incompatible. +!!! error TS2416: Type 'string | DerivedInterface' is not assignable to type 'string | Base'. +!!! error TS2416: Type 'DerivedInterface' is not assignable to type 'string | Base'. +!!! error TS2416: Type 'DerivedInterface' is not assignable to type 'Base'. + fn() { + ~~ +!!! error TS2416: Property 'fn' in type 'DerivedInterface' is not assignable to the same property in base type '() => number'. +!!! error TS2416: Type '() => string | number' is not assignable to type '() => number'. +!!! error TS2416: Type 'string | number' is not assignable to type 'number'. +!!! error TS2416: Type 'string' is not assignable to type 'number'. + return 10 as number | string; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/baseClassImprovedMismatchErrors.js b/tests/baselines/reference/baseClassImprovedMismatchErrors.js new file mode 100644 index 00000000000..296f9e6eb1c --- /dev/null +++ b/tests/baselines/reference/baseClassImprovedMismatchErrors.js @@ -0,0 +1,57 @@ +//// [baseClassImprovedMismatchErrors.ts] +class Base { + n: Base | string; + fn() { + return 10; + } +} +class Derived extends Base { + n: Derived | string; + fn() { + return 10 as number | string; + } +} +class DerivedInterface implements Base { + n: DerivedInterface | string; + fn() { + return 10 as number | string; + } +} + +//// [baseClassImprovedMismatchErrors.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Base = /** @class */ (function () { + function Base() { + } + Base.prototype.fn = function () { + return 10; + }; + return Base; +}()); +var Derived = /** @class */ (function (_super) { + __extends(Derived, _super); + function Derived() { + return _super !== null && _super.apply(this, arguments) || this; + } + Derived.prototype.fn = function () { + return 10; + }; + return Derived; +}(Base)); +var DerivedInterface = /** @class */ (function () { + function DerivedInterface() { + } + DerivedInterface.prototype.fn = function () { + return 10; + }; + return DerivedInterface; +}()); diff --git a/tests/baselines/reference/baseClassImprovedMismatchErrors.symbols b/tests/baselines/reference/baseClassImprovedMismatchErrors.symbols new file mode 100644 index 00000000000..19ac124a2e0 --- /dev/null +++ b/tests/baselines/reference/baseClassImprovedMismatchErrors.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/baseClassImprovedMismatchErrors.ts === +class Base { +>Base : Symbol(Base, Decl(baseClassImprovedMismatchErrors.ts, 0, 0)) + + n: Base | string; +>n : Symbol(Base.n, Decl(baseClassImprovedMismatchErrors.ts, 0, 12)) +>Base : Symbol(Base, Decl(baseClassImprovedMismatchErrors.ts, 0, 0)) + + fn() { +>fn : Symbol(Base.fn, Decl(baseClassImprovedMismatchErrors.ts, 1, 21)) + + return 10; + } +} +class Derived extends Base { +>Derived : Symbol(Derived, Decl(baseClassImprovedMismatchErrors.ts, 5, 1)) +>Base : Symbol(Base, Decl(baseClassImprovedMismatchErrors.ts, 0, 0)) + + n: Derived | string; +>n : Symbol(Derived.n, Decl(baseClassImprovedMismatchErrors.ts, 6, 28)) +>Derived : Symbol(Derived, Decl(baseClassImprovedMismatchErrors.ts, 5, 1)) + + fn() { +>fn : Symbol(Derived.fn, Decl(baseClassImprovedMismatchErrors.ts, 7, 24)) + + return 10 as number | string; + } +} +class DerivedInterface implements Base { +>DerivedInterface : Symbol(DerivedInterface, Decl(baseClassImprovedMismatchErrors.ts, 11, 1)) +>Base : Symbol(Base, Decl(baseClassImprovedMismatchErrors.ts, 0, 0)) + + n: DerivedInterface | string; +>n : Symbol(DerivedInterface.n, Decl(baseClassImprovedMismatchErrors.ts, 12, 40)) +>DerivedInterface : Symbol(DerivedInterface, Decl(baseClassImprovedMismatchErrors.ts, 11, 1)) + + fn() { +>fn : Symbol(DerivedInterface.fn, Decl(baseClassImprovedMismatchErrors.ts, 13, 33)) + + return 10 as number | string; + } +} diff --git a/tests/baselines/reference/baseClassImprovedMismatchErrors.types b/tests/baselines/reference/baseClassImprovedMismatchErrors.types new file mode 100644 index 00000000000..0ca00a02248 --- /dev/null +++ b/tests/baselines/reference/baseClassImprovedMismatchErrors.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/baseClassImprovedMismatchErrors.ts === +class Base { +>Base : Base + + n: Base | string; +>n : string | Base +>Base : Base + + fn() { +>fn : () => number + + return 10; +>10 : 10 + } +} +class Derived extends Base { +>Derived : Derived +>Base : Base + + n: Derived | string; +>n : string | Derived +>Derived : Derived + + fn() { +>fn : () => string | number + + return 10 as number | string; +>10 as number | string : string | number +>10 : 10 + } +} +class DerivedInterface implements Base { +>DerivedInterface : DerivedInterface +>Base : Base + + n: DerivedInterface | string; +>n : string | DerivedInterface +>DerivedInterface : DerivedInterface + + fn() { +>fn : () => string | number + + return 10 as number | string; +>10 as number | string : string | number +>10 : 10 + } +} diff --git a/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt b/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt index 88176d95026..3070a041748 100644 --- a/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt +++ b/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt @@ -1,7 +1,6 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(11,7): error TS2415: Class 'Derived2' incorrectly extends base class 'Base<{ bar: string; }>'. - Types of property 'foo' are incompatible. - Type '{ bar?: string; }' is not assignable to type '{ bar: string; }'. - Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(12,5): error TS2416: Property 'foo' in type 'Derived2' is not assignable to the same property in base type '{ bar: string; }'. + Type '{ bar?: string; }' is not assignable to type '{ bar: string; }'. + Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts (1 errors) ==== @@ -16,12 +15,11 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla } class Derived2 extends Base<{ bar: string; }> { - ~~~~~~~~ -!!! error TS2415: Class 'Derived2' incorrectly extends base class 'Base<{ bar: string; }>'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type '{ bar?: string; }' is not assignable to type '{ bar: string; }'. -!!! error TS2415: Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'. foo: { + ~~~ +!!! error TS2416: Property 'foo' in type 'Derived2' is not assignable to the same property in base type '{ bar: string; }'. +!!! error TS2416: Type '{ bar?: string; }' is not assignable to type '{ bar: string; }'. +!!! error TS2416: Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'. bar?: string; // error } } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.errors.txt b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.errors.txt index f8e237a83ce..ca154600c9f 100644 --- a/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.errors.txt +++ b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.errors.txt @@ -1,8 +1,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassFunctionOverridesBaseClassAccessor.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassFunctionOverridesBaseClassAccessor.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassFunctionOverridesBaseClassAccessor.ts(10,7): error TS2415: Class 'Derived' incorrectly extends base class 'Base'. - Types of property 'x' are incompatible. - Type '() => number' is not assignable to type 'number'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassFunctionOverridesBaseClassAccessor.ts(11,5): error TS2416: Property 'x' in type 'Derived' is not assignable to the same property in base type 'number'. + Type '() => number' is not assignable to type 'number'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassFunctionOverridesBaseClassAccessor.ts(11,5): error TS2426: Class 'Base' defines instance member accessor 'x', but extended class 'Derived' defines it as instance member function. @@ -21,12 +20,11 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassFun // error class Derived extends Base { - ~~~~~~~ -!!! error TS2415: Class 'Derived' incorrectly extends base class 'Base'. -!!! error TS2415: Types of property 'x' are incompatible. -!!! error TS2415: Type '() => number' is not assignable to type 'number'. x() { ~ +!!! error TS2416: Property 'x' in type 'Derived' is not assignable to the same property in base type 'number'. +!!! error TS2416: Type '() => number' is not assignable to type 'number'. + ~ !!! error TS2426: Class 'Base' defines instance member accessor 'x', but extended class 'Derived' defines it as instance member function. return 1; } diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt index 96b93423660..9cc122c7588 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt @@ -34,13 +34,12 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(46,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(47,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(55,7): error TS2420: Class 'C4' incorrectly implements interface 'F2'. - Types of property 'd4' are incompatible. - Type '({ x, y, c }: { x: any; y: any; c: any; }) => void' is not assignable to type '({ x, y, z }?: { x: any; y: any; z: any; }) => any'. - Types of parameters '__0' and '__0' are incompatible. - Type '{ x: any; y: any; z: any; }' is not assignable to type '{ x: any; y: any; c: any; }'. - Property 'c' is missing in type '{ x: any; y: any; z: any; }'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(56,8): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(57,5): error TS2416: Property 'd4' in type 'C4' is not assignable to the same property in base type '({ x, y, z }?: { x: any; y: any; z: any; }) => any'. + Type '({ x, y, c }: { x: any; y: any; c: any; }) => void' is not assignable to type '({ x, y, z }?: { x: any; y: any; z: any; }) => any'. + Types of parameters '__0' and '__0' are incompatible. + Type '{ x: any; y: any; z: any; }' is not assignable to type '{ x: any; y: any; c: any; }'. + Property 'c' is missing in type '{ x: any; y: any; z: any; }'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(65,18): error TS2300: Duplicate identifier 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(65,26): error TS2300: Duplicate identifier 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(65,34): error TS2300: Duplicate identifier 'number'. @@ -155,17 +154,16 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( } class C4 implements F2 { - ~~ -!!! error TS2420: Class 'C4' incorrectly implements interface 'F2'. -!!! error TS2420: Types of property 'd4' are incompatible. -!!! error TS2420: Type '({ x, y, c }: { x: any; y: any; c: any; }) => void' is not assignable to type '({ x, y, z }?: { x: any; y: any; z: any; }) => any'. -!!! error TS2420: Types of parameters '__0' and '__0' are incompatible. -!!! error TS2420: Type '{ x: any; y: any; z: any; }' is not assignable to type '{ x: any; y: any; c: any; }'. -!!! error TS2420: Property 'c' is missing in type '{ x: any; y: any; z: any; }'. d3([a, b, c]?) { } // Error, binding pattern can't be optional in implementation signature ~~~~~~~~~~ !!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. d4({x, y, c}) { } + ~~ +!!! error TS2416: Property 'd4' in type 'C4' is not assignable to the same property in base type '({ x, y, z }?: { x: any; y: any; z: any; }) => any'. +!!! error TS2416: Type '({ x, y, c }: { x: any; y: any; c: any; }) => void' is not assignable to type '({ x, y, z }?: { x: any; y: any; z: any; }) => any'. +!!! error TS2416: Types of parameters '__0' and '__0' are incompatible. +!!! error TS2416: Type '{ x: any; y: any; z: any; }' is not assignable to type '{ x: any; y: any; c: any; }'. +!!! error TS2416: Property 'c' is missing in type '{ x: any; y: any; z: any; }'. e0([a, b, q]) { } } diff --git a/tests/baselines/reference/elaboratedErrors.errors.txt b/tests/baselines/reference/elaboratedErrors.errors.txt index 7bc83a19a50..9a05bdc1d1b 100644 --- a/tests/baselines/reference/elaboratedErrors.errors.txt +++ b/tests/baselines/reference/elaboratedErrors.errors.txt @@ -1,6 +1,5 @@ -tests/cases/compiler/elaboratedErrors.ts(10,7): error TS2420: Class 'WorkerFS' incorrectly implements interface 'FileSystem'. - Types of property 'read' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/compiler/elaboratedErrors.ts(11,3): error TS2416: Property 'read' in type 'WorkerFS' is not assignable to the same property in base type 'number'. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/elaboratedErrors.ts(20,1): error TS2322: Type 'Beta' is not assignable to type 'Alpha'. Property 'x' is missing in type 'Beta'. tests/cases/compiler/elaboratedErrors.ts(21,1): error TS2322: Type 'Beta' is not assignable to type 'Alpha'. @@ -20,11 +19,10 @@ tests/cases/compiler/elaboratedErrors.ts(25,1): error TS2322: Type 'Alpha' is no // This should issue a large error, not a small one class WorkerFS implements FileSystem { - ~~~~~~~~ -!!! error TS2420: Class 'WorkerFS' incorrectly implements interface 'FileSystem'. -!!! error TS2420: Types of property 'read' are incompatible. -!!! error TS2420: Type 'string' is not assignable to type 'number'. read: string; + ~~~~ +!!! error TS2416: Property 'read' in type 'WorkerFS' is not assignable to the same property in base type 'number'. +!!! error TS2416: Type 'string' is not assignable to type 'number'. } interface Alpha { x: string; } diff --git a/tests/baselines/reference/genericImplements.errors.txt b/tests/baselines/reference/genericImplements.errors.txt index 7add57989ce..04ae8d0f0cb 100644 --- a/tests/baselines/reference/genericImplements.errors.txt +++ b/tests/baselines/reference/genericImplements.errors.txt @@ -1,7 +1,6 @@ -tests/cases/compiler/genericImplements.ts(8,7): error TS2420: Class 'X' incorrectly implements interface 'I'. - Types of property 'f' are incompatible. - Type '() => T' is not assignable to type '() => T'. - Type 'B' is not assignable to type 'T'. +tests/cases/compiler/genericImplements.ts(9,5): error TS2416: Property 'f' in type 'X' is not assignable to the same property in base type '() => T'. + Type '() => T' is not assignable to type '() => T'. + Type 'B' is not assignable to type 'T'. ==== tests/cases/compiler/genericImplements.ts (1 errors) ==== @@ -13,12 +12,11 @@ tests/cases/compiler/genericImplements.ts(8,7): error TS2420: Class 'X' incorrec // OK class X implements I { - ~ -!!! error TS2420: Class 'X' incorrectly implements interface 'I'. -!!! error TS2420: Types of property 'f' are incompatible. -!!! error TS2420: Type '() => T' is not assignable to type '() => T'. -!!! error TS2420: Type 'B' is not assignable to type 'T'. f(): T { return undefined; } + ~ +!!! error TS2416: Property 'f' in type 'X' is not assignable to the same property in base type '() => T'. +!!! error TS2416: Type '() => T' is not assignable to type '() => T'. +!!! error TS2416: Type 'B' is not assignable to type 'T'. } // { f: () => { b; } } // OK diff --git a/tests/baselines/reference/genericSpecializations1.errors.txt b/tests/baselines/reference/genericSpecializations1.errors.txt index dd7e540661e..b56cc0d7865 100644 --- a/tests/baselines/reference/genericSpecializations1.errors.txt +++ b/tests/baselines/reference/genericSpecializations1.errors.txt @@ -1,13 +1,11 @@ -tests/cases/compiler/genericSpecializations1.ts(5,7): error TS2420: Class 'IntFooBad' incorrectly implements interface 'IFoo'. - Types of property 'foo' are incompatible. - Type '(x: string) => string' is not assignable to type '(x: T) => T'. - Types of parameters 'x' and 'x' are incompatible. - Type 'T' is not assignable to type 'string'. -tests/cases/compiler/genericSpecializations1.ts(9,7): error TS2420: Class 'StringFoo2' incorrectly implements interface 'IFoo'. - Types of property 'foo' are incompatible. - Type '(x: string) => string' is not assignable to type '(x: T) => T'. - Types of parameters 'x' and 'x' are incompatible. - Type 'T' is not assignable to type 'string'. +tests/cases/compiler/genericSpecializations1.ts(6,5): error TS2416: Property 'foo' in type 'IntFooBad' is not assignable to the same property in base type '(x: T) => T'. + Type '(x: string) => string' is not assignable to type '(x: T) => T'. + Types of parameters 'x' and 'x' are incompatible. + Type 'T' is not assignable to type 'string'. +tests/cases/compiler/genericSpecializations1.ts(10,5): error TS2416: Property 'foo' in type 'StringFoo2' is not assignable to the same property in base type '(x: T) => T'. + Type '(x: string) => string' is not assignable to type '(x: T) => T'. + Types of parameters 'x' and 'x' are incompatible. + Type 'T' is not assignable to type 'string'. ==== tests/cases/compiler/genericSpecializations1.ts (2 errors) ==== @@ -16,23 +14,21 @@ tests/cases/compiler/genericSpecializations1.ts(9,7): error TS2420: Class 'Strin } class IntFooBad implements IFoo { - ~~~~~~~~~ -!!! error TS2420: Class 'IntFooBad' incorrectly implements interface 'IFoo'. -!!! error TS2420: Types of property 'foo' are incompatible. -!!! error TS2420: Type '(x: string) => string' is not assignable to type '(x: T) => T'. -!!! error TS2420: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2420: Type 'T' is not assignable to type 'string'. foo(x: string): string { return null; } + ~~~ +!!! error TS2416: Property 'foo' in type 'IntFooBad' is not assignable to the same property in base type '(x: T) => T'. +!!! 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'. } class StringFoo2 implements IFoo { - ~~~~~~~~~~ -!!! error TS2420: Class 'StringFoo2' incorrectly implements interface 'IFoo'. -!!! error TS2420: Types of property 'foo' are incompatible. -!!! error TS2420: Type '(x: string) => string' is not assignable to type '(x: T) => T'. -!!! error TS2420: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2420: Type 'T' is not assignable to type 'string'. foo(x: string): string { return null; } + ~~~ +!!! error TS2416: Property 'foo' in type 'StringFoo2' is not assignable to the same property in base type '(x: T) => T'. +!!! 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'. } class StringFoo3 implements IFoo { diff --git a/tests/baselines/reference/genericSpecializations2.errors.txt b/tests/baselines/reference/genericSpecializations2.errors.txt index 99a6e2a6985..dc59c200d4f 100644 --- a/tests/baselines/reference/genericSpecializations2.errors.txt +++ b/tests/baselines/reference/genericSpecializations2.errors.txt @@ -1,14 +1,12 @@ -tests/cases/compiler/genericSpecializations2.ts(7,7): error TS2720: Class 'IntFooBad' incorrectly implements class 'IFoo'. Did you mean to extend 'IFoo' and inherit its members as a subclass? - Types of property 'foo' are incompatible. - Type '(x: string) => string' is not assignable to type '(x: T) => T'. - Types of parameters 'x' and 'x' are incompatible. - Type 'T' is not assignable to type 'string'. +tests/cases/compiler/genericSpecializations2.ts(8,5): error TS2416: Property 'foo' in type 'IntFooBad' is not assignable to the same property in base type '(x: T) => T'. + Type '(x: string) => string' is not assignable to type '(x: T) => T'. + Types of parameters 'x' and 'x' are incompatible. + Type 'T' is not assignable to type 'string'. tests/cases/compiler/genericSpecializations2.ts(8,9): error TS2368: Type parameter name cannot be 'string'. -tests/cases/compiler/genericSpecializations2.ts(11,7): error TS2720: Class 'StringFoo2' incorrectly implements class 'IFoo'. Did you mean to extend 'IFoo' and inherit its members as a subclass? - Types of property 'foo' are incompatible. - Type '(x: string) => string' is not assignable to type '(x: T) => T'. - Types of parameters 'x' and 'x' are incompatible. - Type 'T' is not assignable to type 'string'. +tests/cases/compiler/genericSpecializations2.ts(12,5): error TS2416: Property 'foo' in type 'StringFoo2' is not assignable to the same property in base type '(x: T) => T'. + Type '(x: string) => string' is not assignable to type '(x: T) => T'. + Types of parameters 'x' and 'x' are incompatible. + Type 'T' is not assignable to type 'string'. tests/cases/compiler/genericSpecializations2.ts(12,9): error TS2368: Type parameter name cannot be 'string'. @@ -20,25 +18,23 @@ tests/cases/compiler/genericSpecializations2.ts(12,9): error TS2368: Type parame } class IntFooBad implements IFoo { - ~~~~~~~~~ -!!! error TS2720: Class 'IntFooBad' incorrectly implements class 'IFoo'. Did you mean to extend 'IFoo' and inherit its members as a subclass? -!!! error TS2720: Types of property 'foo' are incompatible. -!!! error TS2720: Type '(x: string) => string' is not assignable to type '(x: T) => T'. -!!! error TS2720: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2720: Type 'T' is not assignable to type 'string'. foo(x: string): string { return null; } + ~~~ +!!! error TS2416: Property 'foo' in type 'IntFooBad' is not assignable to the same property in base type '(x: T) => T'. +!!! 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'. ~~~~~~ !!! error TS2368: Type parameter name cannot be 'string'. } class StringFoo2 implements IFoo { - ~~~~~~~~~~ -!!! error TS2720: Class 'StringFoo2' incorrectly implements class 'IFoo'. Did you mean to extend 'IFoo' and inherit its members as a subclass? -!!! error TS2720: Types of property 'foo' are incompatible. -!!! error TS2720: Type '(x: string) => string' is not assignable to type '(x: T) => T'. -!!! error TS2720: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2720: Type 'T' is not assignable to type 'string'. foo(x: string): string { return null; } + ~~~ +!!! error TS2416: Property 'foo' in type 'StringFoo2' is not assignable to the same property in base type '(x: T) => T'. +!!! 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'. ~~~~~~ !!! error TS2368: Type parameter name cannot be 'string'. } diff --git a/tests/baselines/reference/genericSpecializations3.errors.txt b/tests/baselines/reference/genericSpecializations3.errors.txt index 87a7d5bcce7..f99872539a9 100644 --- a/tests/baselines/reference/genericSpecializations3.errors.txt +++ b/tests/baselines/reference/genericSpecializations3.errors.txt @@ -1,8 +1,7 @@ -tests/cases/compiler/genericSpecializations3.ts(8,7): error TS2420: Class 'IntFooBad' incorrectly implements interface 'IFoo'. - Types of property 'foo' are incompatible. - Type '(x: string) => string' is not assignable to type '(x: number) => number'. - Types of parameters 'x' and 'x' are incompatible. - Type 'number' is not assignable to type 'string'. +tests/cases/compiler/genericSpecializations3.ts(9,5): error TS2416: Property 'foo' in type 'IntFooBad' is not assignable to the same property in base type '(x: number) => number'. + Type '(x: string) => string' is not assignable to type '(x: number) => number'. + Types of parameters 'x' and 'x' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/compiler/genericSpecializations3.ts(28,1): error TS2322: Type 'StringFoo2' is not assignable to type 'IntFoo'. Types of property 'foo' are incompatible. Type '(x: string) => string' is not assignable to type '(x: number) => number'. @@ -24,13 +23,12 @@ tests/cases/compiler/genericSpecializations3.ts(29,1): error TS2322: Type 'IntFo iFoo.foo(1); class IntFooBad implements IFoo { // error - ~~~~~~~~~ -!!! error TS2420: Class 'IntFooBad' incorrectly implements interface 'IFoo'. -!!! error TS2420: Types of property 'foo' are incompatible. -!!! error TS2420: Type '(x: string) => string' is not assignable to type '(x: number) => number'. -!!! error TS2420: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2420: Type 'number' is not assignable to type 'string'. foo(x: string): string { return null; } + ~~~ +!!! error TS2416: Property 'foo' in type 'IntFooBad' is not assignable to the same property in base type '(x: number) => number'. +!!! error TS2416: Type '(x: string) => string' is not assignable to type '(x: number) => number'. +!!! error TS2416: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2416: Type 'number' is not assignable to type 'string'. } var intFooBad: IntFooBad; diff --git a/tests/baselines/reference/genericTypeWithNonGenericBaseMisMatch.errors.txt b/tests/baselines/reference/genericTypeWithNonGenericBaseMisMatch.errors.txt index 3ec6fa5e9f6..d91eb2b864e 100644 --- a/tests/baselines/reference/genericTypeWithNonGenericBaseMisMatch.errors.txt +++ b/tests/baselines/reference/genericTypeWithNonGenericBaseMisMatch.errors.txt @@ -1,8 +1,7 @@ -tests/cases/compiler/genericTypeWithNonGenericBaseMisMatch.ts(4,7): error TS2420: Class 'X' incorrectly implements interface 'I'. - Types of property 'f' are incompatible. - Type '(a: T) => void' is not assignable to type '(a: { a: number; }) => void'. - Types of parameters 'a' and 'a' are incompatible. - Type '{ a: number; }' is not assignable to type 'T'. +tests/cases/compiler/genericTypeWithNonGenericBaseMisMatch.ts(5,2): error TS2416: Property 'f' in type 'X' is not assignable to the same property in base type '(a: { a: number; }) => void'. + Type '(a: T) => void' is not assignable to type '(a: { a: number; }) => void'. + Types of parameters 'a' and 'a' are incompatible. + Type '{ a: number; }' is not assignable to type 'T'. tests/cases/compiler/genericTypeWithNonGenericBaseMisMatch.ts(8,5): error TS2322: Type 'X<{ a: string; }>' is not assignable to type 'I'. Types of property 'f' are incompatible. Type '(a: { a: string; }) => void' is not assignable to type '(a: { a: number; }) => void'. @@ -17,13 +16,12 @@ tests/cases/compiler/genericTypeWithNonGenericBaseMisMatch.ts(8,5): error TS2322 f: (a: { a: number }) => void } class X implements I { - ~ -!!! error TS2420: Class 'X' incorrectly implements interface 'I'. -!!! error TS2420: Types of property 'f' are incompatible. -!!! error TS2420: Type '(a: T) => void' is not assignable to type '(a: { a: number; }) => void'. -!!! error TS2420: Types of parameters 'a' and 'a' are incompatible. -!!! error TS2420: Type '{ a: number; }' is not assignable to type 'T'. f(a: T): void { } + ~ +!!! error TS2416: Property 'f' in type 'X' is not assignable to the same property in base type '(a: { a: number; }) => void'. +!!! error TS2416: Type '(a: T) => void' is not assignable to type '(a: { a: number; }) => void'. +!!! error TS2416: Types of parameters 'a' and 'a' are incompatible. +!!! error TS2416: Type '{ a: number; }' is not assignable to type 'T'. } var x = new X<{ a: string }>(); var i: I = x; // Should not be allowed -- type of 'f' is incompatible with 'I' diff --git a/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt b/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt index 4652acc8d10..994174eb84c 100644 --- a/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt +++ b/tests/baselines/reference/implementGenericWithMismatchedTypes.errors.txt @@ -1,12 +1,10 @@ -tests/cases/compiler/implementGenericWithMismatchedTypes.ts(7,7): error TS2420: Class 'C' incorrectly implements interface 'IFoo'. - Types of property 'foo' are incompatible. - Type '(x: string) => number' is not assignable to type '(x: T) => T'. - Types of parameters 'x' and 'x' are incompatible. - Type 'T' is not assignable to type 'string'. -tests/cases/compiler/implementGenericWithMismatchedTypes.ts(16,7): error TS2420: Class 'C2' incorrectly implements interface 'IFoo2'. - Types of property 'foo' are incompatible. - Type '(x: Tstring) => number' is not assignable to type '(x: T) => T'. - Type 'number' is not assignable to type 'T'. +tests/cases/compiler/implementGenericWithMismatchedTypes.ts(8,5): error TS2416: Property 'foo' in type 'C' is not assignable to the same property in base type '(x: T) => T'. + Type '(x: string) => number' is not assignable to type '(x: T) => T'. + Types of parameters 'x' and 'x' are incompatible. + Type 'T' is not assignable to type 'string'. +tests/cases/compiler/implementGenericWithMismatchedTypes.ts(17,5): error TS2416: Property 'foo' in type 'C2' is not assignable to the same property in base type '(x: T) => T'. + Type '(x: Tstring) => number' is not assignable to type '(x: T) => T'. + Type 'number' is not assignable to type 'T'. ==== tests/cases/compiler/implementGenericWithMismatchedTypes.ts (2 errors) ==== @@ -17,13 +15,12 @@ tests/cases/compiler/implementGenericWithMismatchedTypes.ts(16,7): error TS2420: foo(x: T): T; } class C implements IFoo { // error - ~ -!!! error TS2420: Class 'C' incorrectly implements interface 'IFoo'. -!!! error TS2420: Types of property 'foo' are incompatible. -!!! error TS2420: Type '(x: string) => number' is not assignable to type '(x: T) => T'. -!!! error TS2420: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2420: Type 'T' is not assignable to type 'string'. foo(x: string): number { + ~~~ +!!! error TS2416: Property 'foo' in type 'C' is not assignable to the same property in base type '(x: T) => T'. +!!! 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'. return null; } } @@ -32,12 +29,11 @@ tests/cases/compiler/implementGenericWithMismatchedTypes.ts(16,7): error TS2420: foo(x: T): T; } class C2 implements IFoo2 { // error - ~~ -!!! error TS2420: Class 'C2' incorrectly implements interface 'IFoo2'. -!!! error TS2420: Types of property 'foo' are incompatible. -!!! error TS2420: Type '(x: Tstring) => number' is not assignable to type '(x: T) => T'. -!!! error TS2420: Type 'number' is not assignable to type 'T'. foo(x: Tstring): number { + ~~~ +!!! error TS2416: Property 'foo' in type 'C2' is not assignable to the same property in base type '(x: T) => T'. +!!! error TS2416: Type '(x: Tstring) => number' is not assignable to type '(x: T) => T'. +!!! error TS2416: Type 'number' is not assignable to type 'T'. return null; } } \ No newline at end of file diff --git a/tests/baselines/reference/implementsIncorrectlyNoAssertion.errors.txt b/tests/baselines/reference/implementsIncorrectlyNoAssertion.errors.txt index a1c0f21b8c4..7b717545e77 100644 --- a/tests/baselines/reference/implementsIncorrectlyNoAssertion.errors.txt +++ b/tests/baselines/reference/implementsIncorrectlyNoAssertion.errors.txt @@ -1,7 +1,5 @@ -tests/cases/compiler/implementsIncorrectlyNoAssertion.ts(8,7): error TS2420: Class 'Baz' incorrectly implements interface 'Foo & Bar'. - Type 'Baz' is not assignable to type 'Foo'. - Types of property 'x' are incompatible. - Type 'number' is not assignable to type 'string'. +tests/cases/compiler/implementsIncorrectlyNoAssertion.ts(9,5): error TS2416: Property 'x' in type 'Baz' is not assignable to the same property in base type 'string'. + Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/implementsIncorrectlyNoAssertion.ts (1 errors) ==== @@ -13,12 +11,10 @@ tests/cases/compiler/implementsIncorrectlyNoAssertion.ts(8,7): error TS2420: Cla } type Wrapper = Foo & Bar; class Baz implements Wrapper { - ~~~ -!!! error TS2420: Class 'Baz' incorrectly implements interface 'Foo & Bar'. -!!! error TS2420: Type 'Baz' is not assignable to type 'Foo'. -!!! error TS2420: Types of property 'x' are incompatible. -!!! error TS2420: Type 'number' is not assignable to type 'string'. x: number; + ~ +!!! error TS2416: Property 'x' in type 'Baz' is not assignable to the same property in base type 'string'. +!!! error TS2416: Type 'number' is not assignable to type 'string'. y: string; } \ No newline at end of file diff --git a/tests/baselines/reference/incompatibleTypes.errors.txt b/tests/baselines/reference/incompatibleTypes.errors.txt index 4cd68470007..1feed1a3fb6 100644 --- a/tests/baselines/reference/incompatibleTypes.errors.txt +++ b/tests/baselines/reference/incompatibleTypes.errors.txt @@ -1,19 +1,15 @@ -tests/cases/compiler/incompatibleTypes.ts(5,7): error TS2420: Class 'C1' incorrectly implements interface 'IFoo1'. - Types of property 'p1' are incompatible. - Type '() => string' is not assignable to type '() => number'. +tests/cases/compiler/incompatibleTypes.ts(6,12): error TS2416: Property 'p1' in type 'C1' is not assignable to the same property in base type '() => number'. + Type '() => string' is not assignable to type '() => number'. + Type 'string' is not assignable to type 'number'. +tests/cases/compiler/incompatibleTypes.ts(16,12): error TS2416: Property 'p1' in type 'C2' is not assignable to the same property in base type '(s: string) => number'. + Type '(n: number) => number' is not assignable to type '(s: string) => number'. + Types of parameters 'n' and 's' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/compiler/incompatibleTypes.ts(15,7): error TS2420: Class 'C2' incorrectly implements interface 'IFoo2'. - Types of property 'p1' are incompatible. - Type '(n: number) => number' is not assignable to type '(s: string) => number'. - Types of parameters 'n' and 's' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/compiler/incompatibleTypes.ts(25,7): error TS2420: Class 'C3' incorrectly implements interface 'IFoo3'. - Types of property 'p1' are incompatible. - Type 'number' is not assignable to type 'string'. -tests/cases/compiler/incompatibleTypes.ts(33,7): error TS2420: Class 'C4' incorrectly implements interface 'IFoo4'. - Types of property 'p1' are incompatible. - Type '{ c: { b: string; }; d: string; }' is not assignable to type '{ a: { a: string; }; b: string; }'. - Property 'a' is missing in type '{ c: { b: string; }; d: string; }'. +tests/cases/compiler/incompatibleTypes.ts(26,12): error TS2416: Property 'p1' in type 'C3' is not assignable to the same property in base type 'string'. + Type 'number' is not assignable to type 'string'. +tests/cases/compiler/incompatibleTypes.ts(34,12): error TS2416: Property 'p1' in type 'C4' is not assignable to the same property in base type '{ a: { a: string; }; b: string; }'. + Type '{ c: { b: string; }; d: string; }' is not assignable to type '{ a: { a: string; }; b: string; }'. + Property 'a' is missing in type '{ c: { b: string; }; d: string; }'. tests/cases/compiler/incompatibleTypes.ts(42,5): error TS2345: Argument of type 'C1' is not assignable to parameter of type 'IFoo2'. Types of property 'p1' are incompatible. Type '() => string' is not assignable to type '(s: string) => number'. @@ -32,12 +28,11 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => } class C1 implements IFoo1 { // incompatible on the return type - ~~ -!!! error TS2420: Class 'C1' incorrectly implements interface 'IFoo1'. -!!! error TS2420: Types of property 'p1' are incompatible. -!!! error TS2420: Type '() => string' is not assignable to type '() => number'. -!!! error TS2420: Type 'string' is not assignable to type 'number'. public p1() { + ~~ +!!! error TS2416: Property 'p1' in type 'C1' is not assignable to the same property in base type '() => number'. +!!! error TS2416: Type '() => string' is not assignable to type '() => number'. +!!! error TS2416: Type 'string' is not assignable to type 'number'. return "s"; } } @@ -47,13 +42,12 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => } class C2 implements IFoo2 { // incompatible on the param type - ~~ -!!! error TS2420: Class 'C2' incorrectly implements interface 'IFoo2'. -!!! error TS2420: Types of property 'p1' are incompatible. -!!! error TS2420: Type '(n: number) => number' is not assignable to type '(s: string) => number'. -!!! error TS2420: Types of parameters 'n' and 's' are incompatible. -!!! error TS2420: Type 'string' is not assignable to type 'number'. public p1(n:number) { + ~~ +!!! error TS2416: Property 'p1' in type 'C2' is not assignable to the same property in base type '(s: string) => number'. +!!! error TS2416: Type '(n: number) => number' is not assignable to type '(s: string) => number'. +!!! error TS2416: Types of parameters 'n' and 's' are incompatible. +!!! error TS2416: Type 'string' is not assignable to type 'number'. return 0; } } @@ -63,11 +57,10 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => } class C3 implements IFoo3 { // incompatible on the property type - ~~ -!!! error TS2420: Class 'C3' incorrectly implements interface 'IFoo3'. -!!! error TS2420: Types of property 'p1' are incompatible. -!!! error TS2420: Type 'number' is not assignable to type 'string'. public p1: number; + ~~ +!!! error TS2416: Property 'p1' in type 'C3' is not assignable to the same property in base type 'string'. +!!! error TS2416: Type 'number' is not assignable to type 'string'. } interface IFoo4 { @@ -75,12 +68,11 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => } class C4 implements IFoo4 { // incompatible on the property type - ~~ -!!! error TS2420: Class 'C4' incorrectly implements interface 'IFoo4'. -!!! error TS2420: Types of property 'p1' are incompatible. -!!! error TS2420: Type '{ c: { b: string; }; d: string; }' is not assignable to type '{ a: { a: string; }; b: string; }'. -!!! error TS2420: Property 'a' is missing in type '{ c: { b: string; }; d: string; }'. public p1: { c: { b: string; }; d: string; }; + ~~ +!!! error TS2416: Property 'p1' in type 'C4' is not assignable to the same property in base type '{ a: { a: string; }; b: string; }'. +!!! error TS2416: Type '{ c: { b: string; }; d: string; }' is not assignable to type '{ a: { a: string; }; b: string; }'. +!!! error TS2416: Property 'a' is missing in type '{ c: { b: string; }; d: string; }'. } function if1(i: IFoo1): void; diff --git a/tests/baselines/reference/inheritance.errors.txt b/tests/baselines/reference/inheritance.errors.txt index c667e8b001e..429eb2674df 100644 --- a/tests/baselines/reference/inheritance.errors.txt +++ b/tests/baselines/reference/inheritance.errors.txt @@ -1,7 +1,6 @@ -tests/cases/compiler/inheritance.ts(30,7): error TS2415: Class 'Baad' incorrectly extends base class 'Good'. - Types of property 'g' are incompatible. - Type '(n: number) => number' is not assignable to type '() => number'. tests/cases/compiler/inheritance.ts(31,12): error TS2425: Class 'Good' defines instance member property 'f', but extended class 'Baad' defines it as instance member function. +tests/cases/compiler/inheritance.ts(32,12): error TS2416: Property 'g' in type 'Baad' is not assignable to the same property in base type '() => number'. + Type '(n: number) => number' is not assignable to type '() => number'. ==== tests/cases/compiler/inheritance.ts (2 errors) ==== @@ -35,13 +34,12 @@ tests/cases/compiler/inheritance.ts(31,12): error TS2425: Class 'Good' defines i } class Baad extends Good { - ~~~~ -!!! error TS2415: Class 'Baad' incorrectly extends base class 'Good'. -!!! error TS2415: Types of property 'g' are incompatible. -!!! error TS2415: Type '(n: number) => number' is not assignable to type '() => number'. public f(): number { return 0; } ~ !!! error TS2425: Class 'Good' defines instance member property 'f', but extended class 'Baad' defines it as instance member function. public g(n: number) { return 0; } + ~ +!!! error TS2416: Property 'g' in type 'Baad' is not assignable to the same property in base type '() => number'. +!!! error TS2416: Type '(n: number) => number' is not assignable to type '() => number'. } \ No newline at end of file diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt index 6fde83e08b0..a0c20277333 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt @@ -1,12 +1,13 @@ -tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(7,7): error TS2415: Class 'b' incorrectly extends base class 'a'. - Types of property 'x' are incompatible. - Type 'string' is not assignable to type '() => string'. tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(8,9): error TS2416: Property 'x' in type 'b' is not assignable to the same property in base type '() => string'. + Type 'string' is not assignable to type '() => string'. tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(8,9): error TS2423: Class 'a' defines instance member function 'x', but extended class 'b' defines it as instance member accessor. tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(11,9): error TS2416: Property 'x' in type 'b' is not assignable to the same property in base type '() => string'. + Type 'string' is not assignable to type '() => string'. -==== tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts (4 errors) ==== +==== tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts (5 errors) ==== class a { x() { return "20"; @@ -14,20 +15,22 @@ tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(11,9): error T } class b extends a { - ~ -!!! error TS2415: Class 'b' incorrectly extends base class 'a'. -!!! error TS2415: Types of property 'x' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type '() => string'. get x() { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~ +!!! error TS2416: Property 'x' in type 'b' is not assignable to the same property in base type '() => string'. +!!! error TS2416: Type 'string' is not assignable to type '() => string'. + ~ !!! error TS2423: Class 'a' defines instance member function 'x', but extended class 'b' defines it as instance member accessor. return "20"; } set x(aValue: string) { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + ~ +!!! error TS2416: Property 'x' in type 'b' is not assignable to the same property in base type '() => string'. +!!! error TS2416: Type 'string' is not assignable to type '() => string'. } } \ No newline at end of file diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.errors.txt b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.errors.txt index 283e7ce3f18..b31d5d12ec6 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.errors.txt +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.errors.txt @@ -1,8 +1,7 @@ tests/cases/compiler/inheritanceMemberFuncOverridingAccessor.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inheritanceMemberFuncOverridingAccessor.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/inheritanceMemberFuncOverridingAccessor.ts(10,7): error TS2415: Class 'b' incorrectly extends base class 'a'. - Types of property 'x' are incompatible. - Type '() => string' is not assignable to type 'string'. +tests/cases/compiler/inheritanceMemberFuncOverridingAccessor.ts(11,5): error TS2416: Property 'x' in type 'b' is not assignable to the same property in base type 'string'. + Type '() => string' is not assignable to type 'string'. tests/cases/compiler/inheritanceMemberFuncOverridingAccessor.ts(11,5): error TS2426: Class 'a' defines instance member accessor 'x', but extended class 'b' defines it as instance member function. @@ -21,12 +20,11 @@ tests/cases/compiler/inheritanceMemberFuncOverridingAccessor.ts(11,5): error TS2 } class b extends a { - ~ -!!! error TS2415: Class 'b' incorrectly extends base class 'a'. -!!! error TS2415: Types of property 'x' are incompatible. -!!! error TS2415: Type '() => string' is not assignable to type 'string'. x() { ~ +!!! error TS2416: Property 'x' in type 'b' is not assignable to the same property in base type 'string'. +!!! error TS2416: Type '() => string' is not assignable to type 'string'. + ~ !!! error TS2426: Class 'a' defines instance member accessor 'x', but extended class 'b' defines it as instance member function. return "20"; } diff --git a/tests/baselines/reference/instanceSubtypeCheck2.errors.txt b/tests/baselines/reference/instanceSubtypeCheck2.errors.txt index 81982ac3ec7..b1d0f33af08 100644 --- a/tests/baselines/reference/instanceSubtypeCheck2.errors.txt +++ b/tests/baselines/reference/instanceSubtypeCheck2.errors.txt @@ -1,6 +1,5 @@ -tests/cases/compiler/instanceSubtypeCheck2.ts(5,7): error TS2415: Class 'C2' incorrectly extends base class 'C1'. - Types of property 'x' are incompatible. - Type 'string' is not assignable to type 'C2'. +tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2416: Property 'x' in type 'C2' is not assignable to the same property in base type 'C2'. + Type 'string' is not assignable to type 'C2'. ==== tests/cases/compiler/instanceSubtypeCheck2.ts (1 errors) ==== @@ -9,9 +8,8 @@ tests/cases/compiler/instanceSubtypeCheck2.ts(5,7): error TS2415: Class 'C2' } class C2 extends C1 { - ~~ -!!! error TS2415: Class 'C2' incorrectly extends base class 'C1'. -!!! error TS2415: Types of property 'x' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'C2'. x: string + ~ +!!! error TS2416: Property 'x' in type 'C2' is not assignable to the same property in base type 'C2'. +!!! error TS2416: Type 'string' is not assignable to type 'C2'. } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceDeclaration3.errors.txt b/tests/baselines/reference/interfaceDeclaration3.errors.txt index a9bd1d42647..2c29b6a86f2 100644 --- a/tests/baselines/reference/interfaceDeclaration3.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration3.errors.txt @@ -1,9 +1,7 @@ -tests/cases/compiler/interfaceDeclaration3.ts(6,11): error TS2420: Class 'C1' incorrectly implements interface 'I1'. - Types of property 'item' are incompatible. - Type 'number' is not assignable to type 'string'. -tests/cases/compiler/interfaceDeclaration3.ts(31,11): error TS2420: Class 'C1' incorrectly implements interface 'I1'. - Types of property 'item' are incompatible. - Type 'number' is not assignable to type 'string'. +tests/cases/compiler/interfaceDeclaration3.ts(7,16): error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'string'. + Type 'number' is not assignable to type 'string'. +tests/cases/compiler/interfaceDeclaration3.ts(32,16): error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'string'. + Type 'number' is not assignable to type 'string'. tests/cases/compiler/interfaceDeclaration3.ts(54,11): error TS2430: Interface 'I2' incorrectly extends interface 'I1'. Types of property 'item' are incompatible. Type 'string' is not assignable to type 'number'. @@ -16,11 +14,10 @@ tests/cases/compiler/interfaceDeclaration3.ts(54,11): error TS2430: Interface 'I interface I1 { item:string; } interface I2 { item:number; } class C1 implements I1 { - ~~ -!!! error TS2420: Class 'C1' incorrectly implements interface 'I1'. -!!! error TS2420: Types of property 'item' are incompatible. -!!! error TS2420: Type 'number' is not assignable to type 'string'. public item:number; + ~~~~ +!!! error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'string'. +!!! error TS2416: Type 'number' is not assignable to type 'string'. } class C2 implements I1 { public item:string; @@ -45,11 +42,10 @@ tests/cases/compiler/interfaceDeclaration3.ts(54,11): error TS2430: Interface 'I export interface I1 { item:string; } } class C1 implements I1 { - ~~ -!!! error TS2420: Class 'C1' incorrectly implements interface 'I1'. -!!! error TS2420: Types of property 'item' are incompatible. -!!! error TS2420: Type 'number' is not assignable to type 'string'. public item:number; + ~~~~ +!!! error TS2416: Property 'item' in type 'C1' is not assignable to the same property in base type 'string'. +!!! error TS2416: Type 'number' is not assignable to type 'string'. } class C2 implements I1 { public item:string; diff --git a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.errors.txt b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.errors.txt index 035fe89cd35..cac4ba6def7 100644 --- a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.errors.txt +++ b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.errors.txt @@ -2,13 +2,11 @@ tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(10,7): error TS2415: C Types have separate declarations of a private property 'x'. tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(10,7): error TS2420: Class 'D' incorrectly implements interface 'I'. Types have separate declarations of a private property 'x'. -tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(18,7): error TS2415: Class 'D2' incorrectly extends base class 'C'. - Types have separate declarations of a private property 'x'. -tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(18,7): error TS2420: Class 'D2' incorrectly implements interface 'I'. - Types have separate declarations of a private property 'x'. +tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(20,13): error TS2416: Property 'x' in type 'D2' is not assignable to the same property in base type 'number'. + Type 'string' is not assignable to type 'number'. -==== tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts (4 errors) ==== +==== tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts (3 errors) ==== class C { public foo(x: any) { return x; } private x = 1; @@ -33,14 +31,11 @@ tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(18,7): error TS2420: C } class D2 extends C implements I { // error - ~~ -!!! error TS2415: Class 'D2' incorrectly extends base class 'C'. -!!! error TS2415: Types have separate declarations of a private property 'x'. - ~~ -!!! error TS2420: Class 'D2' incorrectly implements interface 'I'. -!!! error TS2420: Types have separate declarations of a private property 'x'. public foo(x: any) { return x; } private x = ""; + ~ +!!! error TS2416: Property 'x' in type 'D2' is not assignable to the same property in base type 'number'. +!!! error TS2416: Type 'string' is not assignable to type 'number'. other(x: any) { return x; } bar() { } } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt index 155cf4bd5ad..6a53fc01c0d 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt @@ -14,22 +14,16 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(11,11): error TS2430: Interface 'I5' incorrectly extends interface 'T5'. Types of property 'c' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(16,7): error TS2415: Class 'C1' incorrectly extends base class 'T1'. - Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,7): error TS2415: Class 'C2' incorrectly extends base class 'T2'. - Type 'C2' is not assignable to type '{ b: number; }'. - Types of property 'b' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(18,7): error TS2415: Class 'C3' incorrectly extends base class 'number[]'. - Types of property 'length' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,7): error TS2415: Class 'C4' incorrectly extends base class '[string, number]'. - Types of property '0' are incompatible. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(20,7): error TS2415: Class 'C5' incorrectly extends base class 'T5'. - Types of property 'c' are incompatible. - Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(16,38): error TS2416: Property 'a' in type 'C1' is not assignable to the same property in base type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,38): error TS2416: Property 'b' in type 'C2' is not assignable to the same property in base type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(18,38): error TS2416: Property 'length' in type 'C3' is not assignable to the same property in base type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,38): error TS2416: Property '0' in type 'C4' is not assignable to the same property in base type 'string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(20,38): error TS2416: Property 'c' in type 'C5' is not assignable to the same property in base type 'string'. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(30,11): error TS2430: Interface 'I10' incorrectly extends interface 'typeof CX'. Types of property 'a' are incompatible. Type 'number' is not assignable to type 'string'. @@ -99,31 +93,25 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI declare function Constructor(): Constructor; class C1 extends Constructor() { a: string } - ~~ -!!! error TS2415: Class 'C1' incorrectly extends base class 'T1'. -!!! error TS2415: Types of property 'a' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2416: Property 'a' in type 'C1' is not assignable to the same property in base type 'number'. +!!! error TS2416: Type 'string' is not assignable to type 'number'. class C2 extends Constructor() { b: string } - ~~ -!!! error TS2415: Class 'C2' incorrectly extends base class 'T2'. -!!! error TS2415: Type 'C2' is not assignable to type '{ b: number; }'. -!!! error TS2415: Types of property 'b' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2416: Property 'b' in type 'C2' is not assignable to the same property in base type 'number'. +!!! error TS2416: Type 'string' is not assignable to type 'number'. class C3 extends Constructor() { length: string } - ~~ -!!! error TS2415: Class 'C3' incorrectly extends base class 'number[]'. -!!! error TS2415: Types of property 'length' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'number'. + ~~~~~~ +!!! error TS2416: Property 'length' in type 'C3' is not assignable to the same property in base type 'number'. +!!! error TS2416: Type 'string' is not assignable to type 'number'. class C4 extends Constructor() { 0: number } - ~~ -!!! error TS2415: Class 'C4' incorrectly extends base class '[string, number]'. -!!! error TS2415: Types of property '0' are incompatible. -!!! error TS2415: Type 'number' is not assignable to type 'string'. + ~ +!!! error TS2416: Property '0' in type 'C4' is not assignable to the same property in base type 'string'. +!!! error TS2416: Type 'number' is not assignable to type 'string'. class C5 extends Constructor() { c: number } - ~~ -!!! error TS2415: Class 'C5' incorrectly extends base class 'T5'. -!!! error TS2415: Types of property 'c' are incompatible. -!!! error TS2415: Type 'number' is not assignable to type 'string'. + ~ +!!! error TS2416: Property 'c' in type 'C5' is not assignable to the same property in base type 'string'. +!!! error TS2416: Type 'number' is not assignable to type 'string'. declare class CX { static a: string } declare enum EX { A, B, C } diff --git a/tests/baselines/reference/interfaceImplementation7.errors.txt b/tests/baselines/reference/interfaceImplementation7.errors.txt index 1025a1f5296..de9bbdae835 100644 --- a/tests/baselines/reference/interfaceImplementation7.errors.txt +++ b/tests/baselines/reference/interfaceImplementation7.errors.txt @@ -1,9 +1,8 @@ tests/cases/compiler/interfaceImplementation7.ts(4,11): error TS2320: Interface 'i3' cannot simultaneously extend types 'i1' and 'i2'. Named property 'name' of types 'i1' and 'i2' are not identical. -tests/cases/compiler/interfaceImplementation7.ts(7,7): error TS2420: Class 'C1' incorrectly implements interface 'i4'. - Types of property 'name' are incompatible. - Type '() => string' is not assignable to type '() => { s: string; n: number; }'. - Type 'string' is not assignable to type '{ s: string; n: number; }'. +tests/cases/compiler/interfaceImplementation7.ts(8,12): error TS2416: Property 'name' in type 'C1' is not assignable to the same property in base type '() => { s: string; n: number; }'. + Type '() => string' is not assignable to type '() => { s: string; n: number; }'. + Type 'string' is not assignable to type '{ s: string; n: number; }'. ==== tests/cases/compiler/interfaceImplementation7.ts (2 errors) ==== @@ -17,11 +16,10 @@ tests/cases/compiler/interfaceImplementation7.ts(7,7): error TS2420: Class 'C1' interface i4 extends i1, i2 { name(): { s: string; n: number; }; } class C1 implements i4 { - ~~ -!!! error TS2420: Class 'C1' incorrectly implements interface 'i4'. -!!! error TS2420: Types of property 'name' are incompatible. -!!! error TS2420: Type '() => string' is not assignable to type '() => { s: string; n: number; }'. -!!! error TS2420: Type 'string' is not assignable to type '{ s: string; n: number; }'. public name(): string { return ""; } + ~~~~ +!!! error TS2416: Property 'name' in type 'C1' is not assignable to the same property in base type '() => { s: string; n: number; }'. +!!! error TS2416: Type '() => string' is not assignable to type '() => { s: string; n: number; }'. +!!! error TS2416: Type 'string' is not assignable to type '{ s: string; n: number; }'. } \ No newline at end of file diff --git a/tests/baselines/reference/mismatchedGenericArguments1.errors.txt b/tests/baselines/reference/mismatchedGenericArguments1.errors.txt index 13618c926ef..4b2d13986ce 100644 --- a/tests/baselines/reference/mismatchedGenericArguments1.errors.txt +++ b/tests/baselines/reference/mismatchedGenericArguments1.errors.txt @@ -1,13 +1,11 @@ -tests/cases/compiler/mismatchedGenericArguments1.ts(4,7): error TS2420: Class 'C' incorrectly implements interface 'IFoo'. - Types of property 'foo' are incompatible. - Type '(x: string) => number' is not assignable to type '(x: T) => T'. - Types of parameters 'x' and 'x' are incompatible. - Type 'T' is not assignable to type 'string'. -tests/cases/compiler/mismatchedGenericArguments1.ts(10,7): error TS2420: Class 'C2' incorrectly implements interface 'IFoo'. - Types of property 'foo' are incompatible. - Type '(x: string) => number' is not assignable to type '(x: T) => T'. - Types of parameters 'x' and 'x' are incompatible. - Type 'T' is not assignable to type 'string'. +tests/cases/compiler/mismatchedGenericArguments1.ts(5,4): error TS2416: Property 'foo' in type 'C' is not assignable to the same property in base type '(x: T) => T'. + Type '(x: string) => number' is not assignable to type '(x: T) => T'. + Types of parameters 'x' and 'x' are incompatible. + Type 'T' is not assignable to type 'string'. +tests/cases/compiler/mismatchedGenericArguments1.ts(11,4): error TS2416: Property 'foo' in type 'C2' is not assignable to the same property in base type '(x: T) => T'. + Type '(x: string) => number' is not assignable to type '(x: T) => T'. + Types of parameters 'x' and 'x' are incompatible. + Type 'T' is not assignable to type 'string'. ==== tests/cases/compiler/mismatchedGenericArguments1.ts (2 errors) ==== @@ -15,25 +13,23 @@ tests/cases/compiler/mismatchedGenericArguments1.ts(10,7): error TS2420: Class ' foo(x: T): T; } class C implements IFoo { - ~ -!!! error TS2420: Class 'C' incorrectly implements interface 'IFoo'. -!!! error TS2420: Types of property 'foo' are incompatible. -!!! error TS2420: Type '(x: string) => number' is not assignable to type '(x: T) => T'. -!!! error TS2420: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2420: Type 'T' is not assignable to type 'string'. foo(x: string): number { + ~~~ +!!! error TS2416: Property 'foo' in type 'C' is not assignable to the same property in base type '(x: T) => T'. +!!! 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'. return null; } } class C2 implements IFoo { - ~~ -!!! error TS2420: Class 'C2' incorrectly implements interface 'IFoo'. -!!! error TS2420: Types of property 'foo' are incompatible. -!!! error TS2420: Type '(x: string) => number' is not assignable to type '(x: T) => T'. -!!! error TS2420: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2420: Type 'T' is not assignable to type 'string'. foo(x: string): number { + ~~~ +!!! error TS2416: Property 'foo' in type 'C2' is not assignable to the same property in base type '(x: T) => T'. +!!! 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'. return null; } } diff --git a/tests/baselines/reference/multipleInheritance.errors.txt b/tests/baselines/reference/multipleInheritance.errors.txt index 19ef1e755e3..72e44dc999c 100644 --- a/tests/baselines/reference/multipleInheritance.errors.txt +++ b/tests/baselines/reference/multipleInheritance.errors.txt @@ -1,9 +1,8 @@ tests/cases/compiler/multipleInheritance.ts(9,21): error TS1174: Classes can only extend a single class. tests/cases/compiler/multipleInheritance.ts(18,21): error TS1174: Classes can only extend a single class. -tests/cases/compiler/multipleInheritance.ts(34,7): error TS2415: Class 'Baad' incorrectly extends base class 'Good'. - Types of property 'g' are incompatible. - Type '(n: number) => number' is not assignable to type '() => number'. tests/cases/compiler/multipleInheritance.ts(35,12): error TS2425: Class 'Good' defines instance member property 'f', but extended class 'Baad' defines it as instance member function. +tests/cases/compiler/multipleInheritance.ts(36,12): error TS2416: Property 'g' in type 'Baad' is not assignable to the same property in base type '() => number'. + Type '(n: number) => number' is not assignable to type '() => number'. ==== tests/cases/compiler/multipleInheritance.ts (4 errors) ==== @@ -45,13 +44,12 @@ tests/cases/compiler/multipleInheritance.ts(35,12): error TS2425: Class 'Good' d } class Baad extends Good { - ~~~~ -!!! error TS2415: Class 'Baad' incorrectly extends base class 'Good'. -!!! error TS2415: Types of property 'g' are incompatible. -!!! error TS2415: Type '(n: number) => number' is not assignable to type '() => number'. public f(): number { return 0; } ~ !!! error TS2425: Class 'Good' defines instance member property 'f', but extended class 'Baad' defines it as instance member function. public g(n:number) { return 0; } + ~ +!!! error TS2416: Property 'g' in type 'Baad' is not assignable to the same property in base type '() => number'. +!!! error TS2416: Type '(n: number) => number' is not assignable to type '() => number'. } \ No newline at end of file diff --git a/tests/baselines/reference/requiredInitializedParameter2.errors.txt b/tests/baselines/reference/requiredInitializedParameter2.errors.txt index 5dcec536e1b..cdb659f251a 100644 --- a/tests/baselines/reference/requiredInitializedParameter2.errors.txt +++ b/tests/baselines/reference/requiredInitializedParameter2.errors.txt @@ -1,6 +1,5 @@ -tests/cases/compiler/requiredInitializedParameter2.ts(5,7): error TS2420: Class 'C1' incorrectly implements interface 'I1'. - Types of property 'method' are incompatible. - Type '(a: number, b: any) => void' is not assignable to type '() => any'. +tests/cases/compiler/requiredInitializedParameter2.ts(6,5): error TS2416: Property 'method' in type 'C1' is not assignable to the same property in base type '() => any'. + Type '(a: number, b: any) => void' is not assignable to type '() => any'. ==== tests/cases/compiler/requiredInitializedParameter2.ts (1 errors) ==== @@ -9,9 +8,8 @@ tests/cases/compiler/requiredInitializedParameter2.ts(5,7): error TS2420: Class } class C1 implements I1 { - ~~ -!!! error TS2420: Class 'C1' incorrectly implements interface 'I1'. -!!! error TS2420: Types of property 'method' are incompatible. -!!! error TS2420: Type '(a: number, b: any) => void' is not assignable to type '() => any'. method(a = 0, b) { } + ~~~~~~ +!!! error TS2416: Property 'method' in type 'C1' is not assignable to the same property in base type '() => any'. +!!! error TS2416: Type '(a: number, b: any) => void' is not assignable to type '() => any'. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt index 14e2275cbf9..f0bed548c97 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt @@ -1,6 +1,5 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(7,7): error TS2415: Class 'D1' incorrectly extends base class 'C3'. - Types of property 'foo' are incompatible. - Type 'U' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(8,5): error TS2416: Property 'foo' in type 'D1' is not assignable to the same property in base type 'T'. + Type 'U' is not assignable to type 'T'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (1 errors) ==== @@ -11,11 +10,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D1 extends C3 { - ~~ -!!! error TS2415: Class 'D1' incorrectly extends base class 'C3'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'U' is not assignable to type 'T'. foo: U; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D1' is not assignable to the same property in base type 'T'. +!!! error TS2416: Type 'U' is not assignable to type 'T'. } function f1(x: T, y: U) { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt index bd7bbeb007e..7019967d204 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt @@ -1,47 +1,37 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(17,7): error TS2415: Class 'D3' incorrectly extends base class 'C3'. - Types of property 'foo' are incompatible. - Type 'U' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(19,5): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'T'. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(19,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(48,7): error TS2415: Class 'D8' incorrectly extends base class 'C3'. - Types of property 'foo' are incompatible. - Type 'U' is not assignable to type 'T'. - Type 'V' is not assignable to type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(65,7): error TS2415: Class 'D11' incorrectly extends base class 'C3'. - Types of property 'foo' are incompatible. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'T'. + Type 'U' is not assignable to type 'T'. Type 'V' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2416: Property 'foo' in type 'D11' is not assignable to the same property in base type 'T'. + Type 'V' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(70,7): error TS2415: Class 'D12' incorrectly extends base class 'C3'. - Types of property 'foo' are incompatible. - Type 'V' is not assignable to type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(72,5): error TS2416: Property 'foo' in type 'D12' is not assignable to the same property in base type 'U'. + Type 'V' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(72,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(110,7): error TS2415: Class 'D19' incorrectly extends base class 'C3'. - Types of property 'foo' are incompatible. - Type 'U' is not assignable to type 'T'. - Type 'V' is not assignable to type 'T'. - Type 'Date' is not assignable to type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(132,7): error TS2415: Class 'D23' incorrectly extends base class 'C3'. - Types of property 'foo' are incompatible. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2416: Property 'foo' in type 'D19' is not assignable to the same property in base type 'T'. + Type 'U' is not assignable to type 'T'. Type 'V' is not assignable to type 'T'. Type 'Date' is not assignable to type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(137,7): error TS2415: Class 'D24' incorrectly extends base class 'C3'. - Types of property 'foo' are incompatible. - Type 'V' is not assignable to type 'U'. - Type 'Date' is not assignable to type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(154,7): error TS2415: Class 'D27' incorrectly extends base class 'C3'. - Types of property 'foo' are incompatible. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2416: Property 'foo' in type 'D23' is not assignable to the same property in base type 'T'. + Type 'V' is not assignable to type 'T'. Type 'Date' is not assignable to type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(159,7): error TS2415: Class 'D28' incorrectly extends base class 'C3'. - Types of property 'foo' are incompatible. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2416: Property 'foo' in type 'D24' is not assignable to the same property in base type 'U'. + Type 'V' is not assignable to type 'U'. Type 'Date' is not assignable to type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2416: Property 'foo' in type 'D27' is not assignable to the same property in base type 'T'. + Type 'Date' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(161,5): error TS2416: Property 'foo' in type 'D28' is not assignable to the same property in base type 'U'. + Type 'Date' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(161,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(164,7): error TS2415: Class 'D29' incorrectly extends base class 'C3'. - Types of property 'foo' are incompatible. - Type 'Date' is not assignable to type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(166,5): error TS2416: Property 'foo' in type 'D29' is not assignable to the same property in base type 'V'. + Type 'Date' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(166,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'V'. @@ -63,12 +53,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D3 extends C3 { - ~~ -!!! error TS2415: Class 'D3' incorrectly extends base class 'C3'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'U' is not assignable to type 'T'. [x: string]: T; foo: U; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'T'. +!!! error TS2416: Type 'U' is not assignable to type 'T'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. } @@ -100,13 +89,12 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf // test if U is a subtype of T, U, V // only a subtype of V and itself class D8 extends C3 { - ~~ -!!! error TS2415: Class 'D8' incorrectly extends base class 'C3'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'U' is not assignable to type 'T'. -!!! error TS2415: Type 'V' is not assignable to type 'T'. [x: string]: T; foo: U; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'T'. +!!! error TS2416: Type 'U' is not assignable to type 'T'. +!!! error TS2416: Type 'V' is not assignable to type 'T'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. } @@ -124,23 +112,21 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf // test if V is a subtype of T, U, V // only a subtype of itself class D11 extends C3 { - ~~~ -!!! error TS2415: Class 'D11' incorrectly extends base class 'C3'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'V' is not assignable to type 'T'. [x: string]: T; foo: V; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D11' is not assignable to the same property in base type 'T'. +!!! error TS2416: Type 'V' is not assignable to type 'T'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. } class D12 extends C3 { - ~~~ -!!! error TS2415: Class 'D12' incorrectly extends base class 'C3'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'V' is not assignable to type 'U'. [x: string]: U; foo: V; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D12' is not assignable to the same property in base type 'U'. +!!! error TS2416: Type 'V' is not assignable to type 'U'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. } @@ -181,14 +167,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D19 extends C3 { - ~~~ -!!! error TS2415: Class 'D19' incorrectly extends base class 'C3'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'U' is not assignable to type 'T'. -!!! error TS2415: Type 'V' is not assignable to type 'T'. -!!! error TS2415: Type 'Date' is not assignable to type 'T'. [x: string]: T; foo: U; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D19' is not assignable to the same property in base type 'T'. +!!! error TS2416: Type 'U' is not assignable to type 'T'. +!!! error TS2416: Type 'V' is not assignable to type 'T'. +!!! error TS2416: Type 'Date' is not assignable to type 'T'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. } @@ -211,25 +196,23 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D23 extends C3 { - ~~~ -!!! error TS2415: Class 'D23' incorrectly extends base class 'C3'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'V' is not assignable to type 'T'. -!!! error TS2415: Type 'Date' is not assignable to type 'T'. [x: string]: T; foo: V; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D23' is not assignable to the same property in base type 'T'. +!!! error TS2416: Type 'V' is not assignable to type 'T'. +!!! error TS2416: Type 'Date' is not assignable to type 'T'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. } class D24 extends C3 { - ~~~ -!!! error TS2415: Class 'D24' incorrectly extends base class 'C3'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'V' is not assignable to type 'U'. -!!! error TS2415: Type 'Date' is not assignable to type 'U'. [x: string]: U; foo: V; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D24' is not assignable to the same property in base type 'U'. +!!! error TS2416: Type 'V' is not assignable to type 'U'. +!!! error TS2416: Type 'Date' is not assignable to type 'U'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. } @@ -247,34 +230,31 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D27 extends C3 { - ~~~ -!!! error TS2415: Class 'D27' incorrectly extends base class 'C3'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'Date' is not assignable to type 'T'. [x: string]: T; foo: Date; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D27' is not assignable to the same property in base type 'T'. +!!! error TS2416: Type 'Date' is not assignable to type 'T'. ~~~~~~~~~~ !!! error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'T'. } class D28 extends C3 { - ~~~ -!!! error TS2415: Class 'D28' incorrectly extends base class 'C3'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'Date' is not assignable to type 'U'. [x: string]: U; foo: Date; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D28' is not assignable to the same property in base type 'U'. +!!! error TS2416: Type 'Date' is not assignable to type 'U'. ~~~~~~~~~~ !!! error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'U'. } class D29 extends C3 { - ~~~ -!!! error TS2415: Class 'D29' incorrectly extends base class 'C3'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'Date' is not assignable to type 'V'. [x: string]: V; foo: Date; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D29' is not assignable to the same property in base type 'V'. +!!! error TS2416: Type 'Date' is not assignable to type 'V'. ~~~~~~~~~~ !!! error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'V'. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index 7b3d706606d..5b1cd0dffa3 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt @@ -1,24 +1,19 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(45,7): error TS2415: Class 'D3' incorrectly extends base class 'B1'. - Types of property 'foo' are incompatible. - Type 'V' is not assignable to type 'Foo'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Foo'. + Type 'V' is not assignable to type 'Foo'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(55,7): error TS2415: Class 'D5' incorrectly extends base class 'B1'. - Types of property 'foo' are incompatible. - Type 'U' is not assignable to type 'T'. - Type 'Foo' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'T'. + Type 'U' is not assignable to type 'T'. + Type 'Foo' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(60,7): error TS2415: Class 'D6' incorrectly extends base class 'B1'. - Types of property 'foo' are incompatible. - Type 'V' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'T'. + Type 'V' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(65,7): error TS2415: Class 'D7' incorrectly extends base class 'B1'. - Types of property 'foo' are incompatible. - Type 'T' is not assignable to type 'U'. - Type 'Foo' is not assignable to type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'U'. + Type 'T' is not assignable to type 'U'. + Type 'Foo' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(75,7): error TS2415: Class 'D9' incorrectly extends base class 'B1'. - Types of property 'foo' are incompatible. - Type 'V' is not assignable to type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2416: Property 'foo' in type 'D9' is not assignable to the same property in base type 'U'. + Type 'V' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. @@ -68,12 +63,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D3 extends B1 { - ~~ -!!! error TS2415: Class 'D3' incorrectly extends base class 'B1'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'V' is not assignable to type 'Foo'. [x: string]: Foo; foo: V; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Foo'. +!!! error TS2416: Type 'V' is not assignable to type 'Foo'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'Foo'. } @@ -84,36 +78,33 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D5 extends B1 { - ~~ -!!! error TS2415: Class 'D5' incorrectly extends base class 'B1'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'U' is not assignable to type 'T'. -!!! error TS2415: Type 'Foo' is not assignable to type 'T'. [x: string]: T; foo: U; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'T'. +!!! error TS2416: Type 'U' is not assignable to type 'T'. +!!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. } class D6 extends B1 { - ~~ -!!! error TS2415: Class 'D6' incorrectly extends base class 'B1'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'V' is not assignable to type 'T'. [x: string]: T; foo: V; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'T'. +!!! error TS2416: Type 'V' is not assignable to type 'T'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. } class D7 extends B1 { - ~~ -!!! error TS2415: Class 'D7' incorrectly extends base class 'B1'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'T' is not assignable to type 'U'. -!!! error TS2415: Type 'Foo' is not assignable to type 'U'. [x: string]: U; foo: T; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'U'. +!!! error TS2416: Type 'T' is not assignable to type 'U'. +!!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. } @@ -124,12 +115,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D9 extends B1 { - ~~ -!!! error TS2415: Class 'D9' incorrectly extends base class 'B1'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'V' is not assignable to type 'U'. [x: string]: U; foo: V; // error + ~~~ +!!! error TS2416: Property 'foo' in type 'D9' is not assignable to the same property in base type 'U'. +!!! error TS2416: Type 'V' is not assignable to type 'U'. ~~~~~~~ !!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt index a7f9d3fad7f..35c086e52a2 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt @@ -1,74 +1,62 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(66,11): error TS2415: Class 'D2' incorrectly extends base class 'Base'. - Types of property 'foo' are incompatible. - Type 'U' is not assignable to type 'T'. - Type 'Foo' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(68,9): error TS2416: Property 'foo' in type 'D2' is not assignable to the same property in base type 'T'. + Type 'U' is not assignable to type 'T'. + Type 'Foo' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(68,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(71,11): error TS2415: Class 'D3' incorrectly extends base class 'Base'. - Types of property 'foo' are incompatible. - Type 'V' is not assignable to type 'T'. - Type 'Foo' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(73,9): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'T'. + Type 'V' is not assignable to type 'T'. + Type 'Foo' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(73,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(76,11): error TS2415: Class 'D4' incorrectly extends base class 'Base'. - Types of property 'foo' are incompatible. - Type 'T' is not assignable to type 'U'. - Type 'Foo' is not assignable to type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(78,9): error TS2416: Property 'foo' in type 'D4' is not assignable to the same property in base type 'U'. + Type 'T' is not assignable to type 'U'. + Type 'Foo' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(78,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(86,11): error TS2415: Class 'D6' incorrectly extends base class 'Base'. - Types of property 'foo' are incompatible. - Type 'V' is not assignable to type 'U'. - Type 'Foo' is not assignable to type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(88,9): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'U'. + Type 'V' is not assignable to type 'U'. + Type 'Foo' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(88,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(91,11): error TS2415: Class 'D7' incorrectly extends base class 'Base'. - Types of property 'foo' are incompatible. - Type 'T' is not assignable to type 'V'. - Type 'Foo' is not assignable to type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(93,9): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'V'. + Type 'T' is not assignable to type 'V'. + Type 'Foo' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(93,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(96,11): error TS2415: Class 'D8' incorrectly extends base class 'Base'. - Types of property 'foo' are incompatible. - Type 'U' is not assignable to type 'V'. - Type 'Foo' is not assignable to type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(98,9): error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'V'. + Type 'U' is not assignable to type 'V'. + Type 'Foo' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(98,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(113,11): error TS2415: Class 'D1' incorrectly extends base class 'Base2'. - Types of property 'foo' are incompatible. - Type 'T' is not assignable to type 'Foo'. - Type 'Foo' is not assignable to type 'Foo'. - Type 'U' is not assignable to type 'T'. - Type 'Foo' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(115,9): error TS2416: Property 'foo' in type 'D1' is not assignable to the same property in base type 'Foo'. + Type 'T' is not assignable to type 'Foo'. + Type 'Foo' is not assignable to type 'Foo'. + Type 'U' is not assignable to type 'T'. + Type 'Foo' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(120,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(123,11): error TS2415: Class 'D3' incorrectly extends base class 'Base2'. - Types of property 'foo' are incompatible. - Type 'V' is not assignable to type 'Foo'. - Type 'Foo' is not assignable to type 'Foo'. - Type 'V' is not assignable to type 'T'. - Type 'Foo' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(125,9): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Foo'. + Type 'V' is not assignable to type 'Foo'. + Type 'Foo' is not assignable to type 'Foo'. + Type 'V' is not assignable to type 'T'. + Type 'Foo' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(125,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(130,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(133,11): error TS2415: Class 'D5' incorrectly extends base class 'Base2'. - Types of property 'foo' are incompatible. - Type 'U' is not assignable to type 'Foo'. - Type 'Foo' is not assignable to type 'Foo'. - Type 'T' is not assignable to type 'U'. - Type 'Foo' is not assignable to type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(138,11): error TS2415: Class 'D6' incorrectly extends base class 'Base2'. - Types of property 'foo' are incompatible. - Type 'V' is not assignable to type 'Foo'. - Type 'Foo' is not assignable to type 'Foo'. - Type 'V' is not assignable to type 'U'. - Type 'Foo' is not assignable to type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(135,9): error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'Foo'. + Type 'U' is not assignable to type 'Foo'. + Type 'Foo' is not assignable to type 'Foo'. + Type 'T' is not assignable to type 'U'. + Type 'Foo' is not assignable to type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(140,9): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Foo'. + Type 'V' is not assignable to type 'Foo'. + Type 'Foo' is not assignable to type 'Foo'. + Type 'V' is not assignable to type 'U'. + Type 'Foo' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(140,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(143,11): error TS2415: Class 'D7' incorrectly extends base class 'Base2'. - Types of property 'foo' are incompatible. - Type 'T' is not assignable to type 'Foo'. - Type 'Foo' is not assignable to type 'Foo'. - Type 'U' is not assignable to type 'V'. - Type 'Foo' is not assignable to type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(145,9): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'Foo'. + Type 'T' is not assignable to type 'Foo'. + Type 'Foo' is not assignable to type 'Foo'. + Type 'U' is not assignable to type 'V'. + Type 'Foo' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(145,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(148,11): error TS2415: Class 'D8' incorrectly extends base class 'Base2'. - Types of property 'foo' are incompatible. - Type 'U' is not assignable to type 'Foo'. - Type 'Foo' is not assignable to type 'Foo'. - Type 'T' is not assignable to type 'V'. - Type 'Foo' is not assignable to type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(150,9): error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'Foo'. + Type 'U' is not assignable to type 'Foo'. + Type 'Foo' is not assignable to type 'Foo'. + Type 'T' is not assignable to type 'V'. + Type 'Foo' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(150,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. @@ -139,37 +127,34 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D2, U extends Foo, V extends Foo> extends Base { - ~~ -!!! error TS2415: Class 'D2' incorrectly extends base class 'Base'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'U' is not assignable to type 'T'. -!!! error TS2415: Type 'Foo' is not assignable to type 'T'. [x: string]: T; foo: U + ~~~ +!!! error TS2416: Property 'foo' in type 'D2' is not assignable to the same property in base type 'T'. +!!! error TS2416: Type 'U' is not assignable to type 'T'. +!!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~~~~ !!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. } class D3, U extends Foo, V extends Foo> extends Base { - ~~ -!!! error TS2415: Class 'D3' incorrectly extends base class 'Base'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'V' is not assignable to type 'T'. -!!! error TS2415: Type 'Foo' is not assignable to type 'T'. [x: string]: T; foo: V + ~~~ +!!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'T'. +!!! error TS2416: Type 'V' is not assignable to type 'T'. +!!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~~~~ !!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. } class D4, U extends Foo, V extends Foo> extends Base { - ~~ -!!! error TS2415: Class 'D4' incorrectly extends base class 'Base'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'T' is not assignable to type 'U'. -!!! error TS2415: Type 'Foo' is not assignable to type 'U'. [x: string]: U; foo: T + ~~~ +!!! error TS2416: Property 'foo' in type 'D4' is not assignable to the same property in base type 'U'. +!!! error TS2416: Type 'T' is not assignable to type 'U'. +!!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~~~~ !!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. } @@ -180,37 +165,34 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D6, U extends Foo, V extends Foo> extends Base { - ~~ -!!! error TS2415: Class 'D6' incorrectly extends base class 'Base'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'V' is not assignable to type 'U'. -!!! error TS2415: Type 'Foo' is not assignable to type 'U'. [x: string]: U; foo: V + ~~~ +!!! error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'U'. +!!! error TS2416: Type 'V' is not assignable to type 'U'. +!!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~~~~ !!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. } class D7, U extends Foo, V extends Foo> extends Base { - ~~ -!!! error TS2415: Class 'D7' incorrectly extends base class 'Base'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'T' is not assignable to type 'V'. -!!! error TS2415: Type 'Foo' is not assignable to type 'V'. [x: string]: V; foo: T + ~~~ +!!! error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'V'. +!!! error TS2416: Type 'T' is not assignable to type 'V'. +!!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~~~~ !!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. } class D8, U extends Foo, V extends Foo> extends Base { - ~~ -!!! error TS2415: Class 'D8' incorrectly extends base class 'Base'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'U' is not assignable to type 'V'. -!!! error TS2415: Type 'Foo' is not assignable to type 'V'. [x: string]: V; foo: U + ~~~ +!!! error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'V'. +!!! error TS2416: Type 'U' is not assignable to type 'V'. +!!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~~~~ !!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. } @@ -228,15 +210,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D1, U extends Foo, V extends Foo> extends Base2 { - ~~ -!!! error TS2415: Class 'D1' incorrectly extends base class 'Base2'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'T' is not assignable to type 'Foo'. -!!! error TS2415: Type 'Foo' is not assignable to type 'Foo'. -!!! error TS2415: Type 'U' is not assignable to type 'T'. -!!! error TS2415: Type 'Foo' is not assignable to type 'T'. [x: string]: T; foo: T + ~~~ +!!! error TS2416: Property 'foo' in type 'D1' is not assignable to the same property in base type 'Foo'. +!!! error TS2416: Type 'T' is not assignable to type 'Foo'. +!!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. +!!! error TS2416: Type 'U' is not assignable to type 'T'. +!!! error TS2416: Type 'Foo' is not assignable to type 'T'. } class D2, U extends Foo, V extends Foo> extends Base2 { @@ -247,15 +228,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D3, U extends Foo, V extends Foo> extends Base2 { - ~~ -!!! error TS2415: Class 'D3' incorrectly extends base class 'Base2'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'V' is not assignable to type 'Foo'. -!!! error TS2415: Type 'Foo' is not assignable to type 'Foo'. -!!! error TS2415: Type 'V' is not assignable to type 'T'. -!!! error TS2415: Type 'Foo' is not assignable to type 'T'. [x: string]: T; foo: V + ~~~ +!!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Foo'. +!!! error TS2416: Type 'V' is not assignable to type 'Foo'. +!!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. +!!! error TS2416: Type 'V' is not assignable to type 'T'. +!!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~~~~ !!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. } @@ -268,55 +248,51 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf } class D5, U extends Foo, V extends Foo> extends Base2 { - ~~ -!!! error TS2415: Class 'D5' incorrectly extends base class 'Base2'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'U' is not assignable to type 'Foo'. -!!! error TS2415: Type 'Foo' is not assignable to type 'Foo'. -!!! error TS2415: Type 'T' is not assignable to type 'U'. -!!! error TS2415: Type 'Foo' is not assignable to type 'U'. [x: string]: U; foo: U + ~~~ +!!! error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'Foo'. +!!! error TS2416: Type 'U' is not assignable to type 'Foo'. +!!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. +!!! error TS2416: Type 'T' is not assignable to type 'U'. +!!! error TS2416: Type 'Foo' is not assignable to type 'U'. } class D6, U extends Foo, V extends Foo> extends Base2 { - ~~ -!!! error TS2415: Class 'D6' incorrectly extends base class 'Base2'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'V' is not assignable to type 'Foo'. -!!! error TS2415: Type 'Foo' is not assignable to type 'Foo'. -!!! error TS2415: Type 'V' is not assignable to type 'U'. -!!! error TS2415: Type 'Foo' is not assignable to type 'U'. [x: string]: U; foo: V + ~~~ +!!! error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Foo'. +!!! error TS2416: Type 'V' is not assignable to type 'Foo'. +!!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. +!!! error TS2416: Type 'V' is not assignable to type 'U'. +!!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~~~~ !!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. } class D7, U extends Foo, V extends Foo> extends Base2 { - ~~ -!!! error TS2415: Class 'D7' incorrectly extends base class 'Base2'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'T' is not assignable to type 'Foo'. -!!! error TS2415: Type 'Foo' is not assignable to type 'Foo'. -!!! error TS2415: Type 'U' is not assignable to type 'V'. -!!! error TS2415: Type 'Foo' is not assignable to type 'V'. [x: string]: V; foo: T + ~~~ +!!! error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'Foo'. +!!! error TS2416: Type 'T' is not assignable to type 'Foo'. +!!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. +!!! error TS2416: Type 'U' is not assignable to type 'V'. +!!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~~~~ !!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. } class D8, U extends Foo, V extends Foo> extends Base2 { - ~~ -!!! error TS2415: Class 'D8' incorrectly extends base class 'Base2'. -!!! error TS2415: Types of property 'foo' are incompatible. -!!! error TS2415: Type 'U' is not assignable to type 'Foo'. -!!! error TS2415: Type 'Foo' is not assignable to type 'Foo'. -!!! error TS2415: Type 'T' is not assignable to type 'V'. -!!! error TS2415: Type 'Foo' is not assignable to type 'V'. [x: string]: V; foo: U + ~~~ +!!! error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'Foo'. +!!! error TS2416: Type 'U' is not assignable to type 'Foo'. +!!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. +!!! error TS2416: Type 'T' is not assignable to type 'V'. +!!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~~~~ !!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. } diff --git a/tests/baselines/reference/subtypingWithObjectMembers.errors.txt b/tests/baselines/reference/subtypingWithObjectMembers.errors.txt index a5d4152b451..2be672f5c03 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers.errors.txt +++ b/tests/baselines/reference/subtypingWithObjectMembers.errors.txt @@ -1,21 +1,15 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(12,7): error TS2415: Class 'B' incorrectly extends base class 'A'. - Types of property 'bar' are incompatible. - Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(22,7): error TS2415: Class 'B2' incorrectly extends base class 'A2'. - Types of property '2.0' are incompatible. - Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(32,7): error TS2415: Class 'B3' incorrectly extends base class 'A3'. - Types of property ''2.0'' are incompatible. - Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(43,11): error TS2415: Class 'B' incorrectly extends base class 'A'. - Types of property 'bar' are incompatible. - Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(53,11): error TS2415: Class 'B2' incorrectly extends base class 'A2'. - Types of property '2.0' are incompatible. - Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(63,11): error TS2415: Class 'B3' incorrectly extends base class 'A3'. - Types of property ''2.0'' are incompatible. - Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(14,5): error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'Base'. + Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(24,5): error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'Base'. + Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(34,5): error TS2416: Property '2.0' in type 'B3' is not assignable to the same property in base type 'Base'. + Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(45,9): error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'Base'. + Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(55,9): error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'Base'. + Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(65,9): error TS2416: Property '2.0' in type 'B3' is not assignable to the same property in base type 'Base'. + Type 'string' is not assignable to type 'Base'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts (6 errors) ==== @@ -31,12 +25,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } class B extends A { - ~ -!!! error TS2415: Class 'B' incorrectly extends base class 'A'. -!!! error TS2415: Types of property 'bar' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'Base'. foo: Derived; // ok bar: string; // error + ~~~ +!!! error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'Base'. +!!! error TS2416: Type 'string' is not assignable to type 'Base'. } class A2 { @@ -45,12 +38,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } class B2 extends A2 { - ~~ -!!! error TS2415: Class 'B2' incorrectly extends base class 'A2'. -!!! error TS2415: Types of property '2.0' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'Base'. 1: Derived; // ok 2: string; // error + ~ +!!! error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'Base'. +!!! error TS2416: Type 'string' is not assignable to type 'Base'. } class A3 { @@ -59,12 +51,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } class B3 extends A3 { - ~~ -!!! error TS2415: Class 'B3' incorrectly extends base class 'A3'. -!!! error TS2415: Types of property ''2.0'' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'Base'. '1': Derived; // ok '2.0': string; // error + ~~~~~ +!!! error TS2416: Property '2.0' in type 'B3' is not assignable to the same property in base type 'Base'. +!!! error TS2416: Type 'string' is not assignable to type 'Base'. } module TwoLevels { @@ -74,12 +65,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } class B extends A { - ~ -!!! error TS2415: Class 'B' incorrectly extends base class 'A'. -!!! error TS2415: Types of property 'bar' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'Base'. foo: Derived2; // ok bar: string; // error + ~~~ +!!! error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'Base'. +!!! error TS2416: Type 'string' is not assignable to type 'Base'. } class A2 { @@ -88,12 +78,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } class B2 extends A2 { - ~~ -!!! error TS2415: Class 'B2' incorrectly extends base class 'A2'. -!!! error TS2415: Types of property '2.0' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'Base'. 1: Derived2; // ok 2: string; // error + ~ +!!! error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'Base'. +!!! error TS2416: Type 'string' is not assignable to type 'Base'. } class A3 { @@ -102,11 +91,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } class B3 extends A3 { - ~~ -!!! error TS2415: Class 'B3' incorrectly extends base class 'A3'. -!!! error TS2415: Types of property ''2.0'' are incompatible. -!!! error TS2415: Type 'string' is not assignable to type 'Base'. '1': Derived2; // ok '2.0': string; // error + ~~~~~ +!!! error TS2416: Property '2.0' in type 'B3' is not assignable to the same property in base type 'Base'. +!!! error TS2416: Type 'string' is not assignable to type 'Base'. } } \ No newline at end of file diff --git a/tests/cases/compiler/baseClassImprovedMismatchErrors.ts b/tests/cases/compiler/baseClassImprovedMismatchErrors.ts new file mode 100644 index 00000000000..5b59d2bc96a --- /dev/null +++ b/tests/cases/compiler/baseClassImprovedMismatchErrors.ts @@ -0,0 +1,18 @@ +class Base { + n: Base | string; + fn() { + return 10; + } +} +class Derived extends Base { + n: Derived | string; + fn() { + return 10 as number | string; + } +} +class DerivedInterface implements Base { + n: DerivedInterface | string; + fn() { + return 10 as number | string; + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/incompatibleOverride.ts b/tests/cases/fourslash/incompatibleOverride.ts index f33e7f226b6..0b3dd323015 100644 --- a/tests/cases/fourslash/incompatibleOverride.ts +++ b/tests/cases/fourslash/incompatibleOverride.ts @@ -3,8 +3,8 @@ // Squiggle for implementing a derived class with an incompatible override is too large //// class Foo { xyz: string; } -//// class /*1*/Bar/*2*/ extends Foo { xyz: number; } -//// class /*3*/Baz/*4*/ extends Foo { public xyz: number; } +//// class Bar extends Foo { /*1*/xyz/*2*/: number; } +//// class Baz extends Foo { public /*3*/xyz/*4*/: number; } //// class /*5*/Baf/*6*/ extends Foo { //// constructor(public xyz: number) { //// super(); diff --git a/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts b/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts index bb7b40fd259..955d461b9f1 100644 --- a/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts +++ b/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts @@ -4,8 +4,8 @@ //// public x: number; ////} //// -////class /*1*/Bar/*2*/ extends Foo { -//// public x: string; +////class Bar extends Foo { +//// public /*1*/x/*2*/: string; ////} verify.errorExistsBetweenMarkers("1", "2");