From ac9673977758afb864137da021f728afc30f7139 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 13 Sep 2019 14:38:09 -0700 Subject: [PATCH 01/17] Disallow uninitialised property overrides This causes quite a few test breaks. We'll probably want to revert many of them by switching to the upcoming `declare x: number` syntax. --- src/compiler/checker.ts | 43 ++-- src/compiler/diagnosticMessages.json | 4 + .../apparentTypeSubtyping.errors.txt | 8 +- .../apparentTypeSupertype.errors.txt | 5 +- ...baseClassImprovedMismatchErrors.errors.txt | 5 +- .../classIsSubtypeOfBaseType.errors.txt | 8 +- ...declarationEmitProtectedMembers.errors.txt | 55 +++++ ...dClassOverridesProtectedMembers.errors.txt | 44 ++++ ...ClassOverridesProtectedMembers2.errors.txt | 72 +++++++ ...ClassOverridesProtectedMembers3.errors.txt | 8 +- ...ClassOverridesProtectedMembers4.errors.txt | 8 +- ...ivedClassOverridesPublicMembers.errors.txt | 8 +- ...vedClassOverridesWithoutSubtype.errors.txt | 29 +++ .../reference/derivedClassWithAny.errors.txt | 8 +- .../derivedGenericClassWithAny.errors.txt | 8 +- ...ninitializedPropertyDeclaration.errors.txt | 22 ++ ...derivedUninitializedPropertyDeclaration.js | 54 +++++ ...edUninitializedPropertyDeclaration.symbols | 28 +++ ...ivedUninitializedPropertyDeclaration.types | 29 +++ .../genericPrototypeProperty2.errors.txt | 24 +++ .../genericPrototypeProperty3.errors.txt | 23 +++ ...aceExtendingClassWithProtecteds.errors.txt | 5 +- .../reference/inheritance.errors.txt | 5 +- ...emberPropertyOverridingAccessor.errors.txt | 5 +- ...emberPropertyOverridingProperty.errors.txt | 13 ++ .../instanceSubtypeCheck2.errors.txt | 5 +- ...erfaceExtendsObjectIntersection.errors.txt | 78 +++++++ ...ExtendsObjectIntersectionErrors.errors.txt | 17 +- .../reference/multipleInheritance.errors.txt | 5 +- .../mutuallyRecursiveInference.errors.txt | 24 +++ .../reference/protectedMembers.errors.txt | 11 +- .../baselines/reference/scopeTests.errors.txt | 5 +- .../subtypesOfTypeParameter.errors.txt | 5 +- ...OfTypeParameterWithConstraints4.errors.txt | 29 ++- ...rameterWithRecursiveConstraints.errors.txt | 56 +++++- .../subtypingTransitivity.errors.txt | 28 +++ .../subtypingWithObjectMembers.errors.txt | 38 +++- .../tsxGenericAttributesType5.errors.txt | 19 ++ .../tsxGenericAttributesType6.errors.txt | 19 ++ .../undefinedIsSubtypeOfEverything.errors.txt | 190 ++++++++++++++++++ ...derivedUninitializedPropertyDeclaration.ts | 12 ++ tests/cases/fourslash/incompatibleOverride.ts | 6 +- .../squiggleIllegalSubclassOverride.ts | 4 +- 43 files changed, 1030 insertions(+), 42 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitProtectedMembers.errors.txt create mode 100644 tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt create mode 100644 tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt create mode 100644 tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt create mode 100644 tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt create mode 100644 tests/baselines/reference/derivedUninitializedPropertyDeclaration.js create mode 100644 tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols create mode 100644 tests/baselines/reference/derivedUninitializedPropertyDeclaration.types create mode 100644 tests/baselines/reference/genericPrototypeProperty2.errors.txt create mode 100644 tests/baselines/reference/genericPrototypeProperty3.errors.txt create mode 100644 tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt create mode 100644 tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt create mode 100644 tests/baselines/reference/mutuallyRecursiveInference.errors.txt create mode 100644 tests/baselines/reference/subtypingTransitivity.errors.txt create mode 100644 tests/baselines/reference/tsxGenericAttributesType5.errors.txt create mode 100644 tests/baselines/reference/tsxGenericAttributesType6.errors.txt create mode 100644 tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f8c8817888591..311b57d1c1701 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29442,22 +29442,22 @@ namespace ts { d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.InterfaceDeclaration); } + /** + * TypeScript 1.0 spec (April 2014): 8.2.3 + * A derived class inherits all members from its base class it doesn't override. + * Inheritance means that a derived class implicitly contains all non - overridden members of the base class. + * Both public and private property members are inherited, but only public property members can be overridden. + * A property member in a derived class is said to override a property member in a base class + * when the derived class property member has the same name and kind(instance or static) + * as the base class property member. + * The type of an overriding property member must be assignable(section 3.8.4) + * to the type of the overridden property member, or otherwise a compile - time error occurs. + * Base class instance member functions can be overridden by derived class instance member functions, + * but not by other kinds of members. + * Base class instance member variables and accessors can be overridden by + * derived class instance member variables and accessors, but not by other kinds of members. + */ function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: BaseType): void { - - // TypeScript 1.0 spec (April 2014): 8.2.3 - // A derived class inherits all members from its base class it doesn't override. - // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. - // Both public and private property members are inherited, but only public property members can be overridden. - // A property member in a derived class is said to override a property member in a base class - // when the derived class property member has the same name and kind(instance or static) - // as the base class property member. - // The type of an overriding property member must be assignable(section 3.8.4) - // to the type of the overridden property member, or otherwise a compile - time error occurs. - // Base class instance member functions can be overridden by derived class instance member functions, - // but not by other kinds of members. - // Base class instance member variables and accessors can be overridden by - // derived class instance member variables and accessors, but not by other kinds of members. - // NOTE: assignability is checked in checkClassDeclaration const baseProperties = getPropertiesOfType(baseType); basePropertyCheck: for (const baseProperty of baseProperties) { @@ -29514,10 +29514,21 @@ namespace ts { continue; } - if (isPrototypeProperty(base) || base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) { + if (isPrototypeProperty(base)) { // method is overridden with method or property/accessor is overridden with property/accessor - correct case continue; } + if (base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) { + if (derived.flags & SymbolFlags.Property + && !(derived.flags & SymbolFlags.Transient) + && !(baseDeclarationFlags & ModifierFlags.Abstract) + && !derived.declarations.some(d => d.flags & NodeFlags.Ambient) + && derived.declarations.some(d => d.kind === SyntaxKind.PropertyDeclaration && !(d as PropertyDeclaration).initializer)) { + const errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_so_extended_class_2_must_provide_an_initializer_with_this_override; + error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + } + continue; + } let errorMessage: DiagnosticMessage; if (isPrototypeProperty(base)) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 86686cb9f6c1b..0200bf4b1b3d4 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2204,6 +2204,10 @@ "category": "Error", "code": 2609 }, + "Class '{0}' defines instance member property '{1}', so extended class '{2}' must provide an initializer with this override.": { + "category": "Error", + "code": 2610 + }, "Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": { "category": "Error", "code": 2649 diff --git a/tests/baselines/reference/apparentTypeSubtyping.errors.txt b/tests/baselines/reference/apparentTypeSubtyping.errors.txt index ca2f0765d6211..92ce3a37c3c35 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.errors.txt +++ b/tests/baselines/reference/apparentTypeSubtyping.errors.txt @@ -1,9 +1,11 @@ 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 'Base'. 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 TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(20,5): error TS2610: Class 'Base2' defines instance member property 'x', so extended class 'Derived2' must provide an initializer with this override. -==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts (1 errors) ==== +==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts (3 errors) ==== // subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: @@ -18,6 +20,8 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi !!! error TS2416: Property 'x' in type 'Derived' is not assignable to the same property in base type 'Base'. !!! 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. + ~ +!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. } class Base2 { @@ -28,4 +32,6 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi // is U extends String (S) a subtype of String (T)? Apparent type of U is String so it succeeds class Derived2 extends Base2 { // error because of the prototype's not matching, not because of the instance side x: U; + ~ +!!! error TS2610: Class 'Base2' defines instance member property 'x', so extended class 'Derived2' must provide an initializer with this override. } \ No newline at end of file diff --git a/tests/baselines/reference/apparentTypeSupertype.errors.txt b/tests/baselines/reference/apparentTypeSupertype.errors.txt index a4a8ccc0a8bdd..23e4ee3cb3512 100644 --- a/tests/baselines/reference/apparentTypeSupertype.errors.txt +++ b/tests/baselines/reference/apparentTypeSupertype.errors.txt @@ -2,9 +2,10 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty 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 TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. -==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (1 errors) ==== +==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (2 errors) ==== // subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: @@ -20,4 +21,6 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty !!! 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. + ~ +!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. } \ No newline at end of file diff --git a/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt b/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt index 5f46ee70d2aaa..9a097955fde14 100644 --- a/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt +++ b/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt @@ -5,6 +5,7 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2416: Prop 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'. +tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2610: Class 'Base' defines instance member property 'n', so extended class 'Derived' must provide an initializer with this override. tests/cases/compiler/baseClassImprovedMismatchErrors.ts(9,5): error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type 'Base'. Type '() => string | number' is not assignable to type '() => number'. Type 'string | number' is not assignable to type 'number'. @@ -22,7 +23,7 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(15,5): error TS2416: Pro Type 'string' is not assignable to type 'number'. -==== tests/cases/compiler/baseClassImprovedMismatchErrors.ts (4 errors) ==== +==== tests/cases/compiler/baseClassImprovedMismatchErrors.ts (5 errors) ==== class Base { n: Base | string; fn() { @@ -39,6 +40,8 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(15,5): error TS2416: Pro !!! 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 TS2610: Class 'Base' defines instance member property 'n', so extended class 'Derived' must provide an initializer with this override. fn() { ~~ !!! error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type 'Base'. diff --git a/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt b/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt index 8b84602b807c5..f59f03763efa0 100644 --- a/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt +++ b/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt @@ -1,15 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(6,5): error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived' must provide an initializer with this override. 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 'Base<{ 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(12,5): error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived2' must provide an initializer with this override. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts (1 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts (3 errors) ==== class Base { foo: T; } class Derived extends Base<{ bar: string; }> { foo: { + ~~~ +!!! error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived' must provide an initializer with this override. bar: string; baz: number; // ok } } @@ -20,6 +24,8 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla !!! error TS2416: Property 'foo' in type 'Derived2' is not assignable to the same property in base type 'Base<{ 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; }'. + ~~~ +!!! error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived2' must provide an initializer with this override. bar?: string; // error } } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt b/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt new file mode 100644 index 0000000000000..ee19970f04d14 --- /dev/null +++ b/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt @@ -0,0 +1,55 @@ +tests/cases/compiler/declarationEmitProtectedMembers.ts(34,5): error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. + + +==== tests/cases/compiler/declarationEmitProtectedMembers.ts (1 errors) ==== + // Class with protected members + class C1 { + protected x: number; + + protected f() { + return this.x; + } + + protected set accessor(a: number) { } + protected get accessor() { return 0; } + + protected static sx: number; + + protected static sf() { + return this.sx; + } + + protected static set staticSetter(a: number) { } + protected static get staticGetter() { return 0; } + } + + // Derived class overriding protected members + class C2 extends C1 { + protected f() { + return super.f() + this.x; + } + protected static sf() { + return super.sf() + this.sx; + } + } + + // Derived class making protected members public + class C3 extends C2 { + x: number; + ~ +!!! error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. + static sx: number; + f() { + return super.f(); + } + static sf() { + return super.sf(); + } + + static get staticGetter() { return 1; } + } + + // Protected properties in constructors + class C4 { + constructor(protected a: number, protected b) { } + } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt new file mode 100644 index 0000000000000..645abc21fc0f1 --- /dev/null +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(21,15): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(25,15): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. + + +==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts (2 errors) ==== + var x: { foo: string; } + var y: { foo: string; bar: string; } + + class Base { + protected a: typeof x; + protected b(a: typeof x) { } + protected get c() { return x; } + protected set c(v: typeof x) { } + protected d: (a: typeof x) => void; + + protected static r: typeof x; + protected static s(a: typeof x) { } + protected static get t() { return x; } + protected static set t(v: typeof x) { } + protected static u: (a: typeof x) => void; + + constructor(a: typeof x) { } + } + + class Derived extends Base { + protected a: typeof y; + ~ +!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. + protected b(a: typeof y) { } + protected get c() { return y; } + protected set c(v: typeof y) { } + protected d: (a: typeof y) => void; + ~ +!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. + + protected static r: typeof y; + protected static s(a: typeof y) { } + protected static get t() { return y; } + protected static set t(a: typeof y) { } + protected static u: (a: typeof y) => void; + + constructor(a: typeof y) { super(x) } + } + \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt new file mode 100644 index 0000000000000..51677922dccda --- /dev/null +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt @@ -0,0 +1,72 @@ +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(22,5): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(26,5): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. + + +==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts (2 errors) ==== + var x: { foo: string; } + var y: { foo: string; bar: string; } + + class Base { + protected a: typeof x; + protected b(a: typeof x) { } + protected get c() { return x; } + protected set c(v: typeof x) { } + protected d: (a: typeof x) => void ; + + protected static r: typeof x; + protected static s(a: typeof x) { } + protected static get t() { return x; } + protected static set t(v: typeof x) { } + protected static u: (a: typeof x) => void ; + + constructor(a: typeof x) { } + } + + // Increase visibility of all protected members to public + class Derived extends Base { + a: typeof y; + ~ +!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. + b(a: typeof y) { } + get c() { return y; } + set c(v: typeof y) { } + d: (a: typeof y) => void; + ~ +!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. + + static r: typeof y; + static s(a: typeof y) { } + static get t() { return y; } + static set t(a: typeof y) { } + static u: (a: typeof y) => void; + + constructor(a: typeof y) { super(a); } + } + + var d: Derived = new Derived(y); + var r1 = d.a; + var r2 = d.b(y); + var r3 = d.c; + var r3a = d.d; + d.c = y; + var r4 = Derived.r; + var r5 = Derived.s(y); + var r6 = Derived.t; + var r6a = Derived.u; + Derived.t = y; + + class Base2 { + [i: string]: Object; + [i: number]: typeof x; + } + + class Derived2 extends Base2 { + [i: string]: typeof x; + [i: number]: typeof y; + } + + var d2: Derived2; + var r7 = d2['']; + var r8 = d2[1]; + + \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt index faf228e8d55c2..6fdb020e366c4 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(22,7): error TS2415: Class 'Derived1' incorrectly extends base class 'Base'. Property 'a' is protected in type 'Derived1' but public in type 'Base'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(23,15): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must provide an initializer with this override. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(27,7): error TS2415: Class 'Derived2' incorrectly extends base class 'Base'. Property 'b' is protected in type 'Derived2' but public in type 'Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(32,7): error TS2415: Class 'Derived3' incorrectly extends base class 'Base'. @@ -8,6 +9,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve Property 'c' is protected in type 'Derived4' but public in type 'Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(42,7): error TS2415: Class 'Derived5' incorrectly extends base class 'Base'. Property 'd' is protected in type 'Derived5' but public in type 'Base'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(43,15): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived5' must provide an initializer with this override. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(47,7): error TS2417: Class static side 'typeof Derived6' incorrectly extends base class static side 'typeof Base'. Property 'r' is protected in type 'typeof Derived6' but public in type 'typeof Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(52,7): error TS2417: Class static side 'typeof Derived7' incorrectly extends base class static side 'typeof Base'. @@ -20,7 +22,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve Property 'u' is protected in type 'typeof Derived10' but public in type 'typeof Base'. -==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts (10 errors) ==== +==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts (12 errors) ==== var x: { foo: string; } var y: { foo: string; bar: string; } @@ -47,6 +49,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve !!! error TS2415: Class 'Derived1' incorrectly extends base class 'Base'. !!! error TS2415: Property 'a' is protected in type 'Derived1' but public in type 'Base'. protected a: typeof x; + ~ +!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must provide an initializer with this override. constructor(a: typeof x) { super(a); } } @@ -79,6 +83,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve !!! error TS2415: Class 'Derived5' incorrectly extends base class 'Base'. !!! error TS2415: Property 'd' is protected in type 'Derived5' but public in type 'Base'. protected d: (a: typeof x) => void ; + ~ +!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived5' must provide an initializer with this override. constructor(a: typeof x) { super(a); } } diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt index 064e2e8d43c2f..00eecd17d899a 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt @@ -1,8 +1,10 @@ +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(9,12): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must provide an initializer with this override. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(12,7): error TS2415: Class 'Derived2' incorrectly extends base class 'Derived1'. Property 'a' is protected in type 'Derived2' but public in type 'Derived1'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(13,15): error TS2610: Class 'Derived1' defines instance member property 'a', so extended class 'Derived2' must provide an initializer with this override. -==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts (1 errors) ==== +==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts (3 errors) ==== var x: { foo: string; } var y: { foo: string; bar: string; } @@ -12,6 +14,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived1 extends Base { public a: typeof x; + ~ +!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must provide an initializer with this override. } class Derived2 extends Derived1 { @@ -19,4 +23,6 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve !!! error TS2415: Class 'Derived2' incorrectly extends base class 'Derived1'. !!! error TS2415: Property 'a' is protected in type 'Derived2' but public in type 'Derived1'. protected a: typeof x; // Error, parent was public + ~ +!!! error TS2610: Class 'Derived1' defines instance member property 'a', so extended class 'Derived2' must provide an initializer with this override. } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt b/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt index 9292ff64411d5..19273eebe347d 100644 --- a/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt @@ -2,13 +2,15 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(13,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(14,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(21,5): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(24,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(25,5): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(29,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(30,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts (8 errors) ==== +==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts (10 errors) ==== var x: { foo: string; } var y: { foo: string; bar: string; } @@ -38,6 +40,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived extends Base { a: typeof y; + ~ +!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. b(a: typeof y) { } get c() { return y; } ~ @@ -46,6 +50,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. d: (a: typeof y) => void; + ~ +!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. static r: typeof y; static s(a: typeof y) { } diff --git a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt new file mode 100644 index 0000000000000..46e01f242e299 --- /dev/null +++ b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesWithoutSubtype.ts(8,5): error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. + + +==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesWithoutSubtype.ts (1 errors) ==== + class Base { + x: { + foo: string; + } + } + + class Derived extends Base { + x: { + ~ +!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. + foo: any; + } + } + + class Base2 { + static y: { + foo: string; + } + } + + class Derived2 extends Base2 { + static y: { + foo: any; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassWithAny.errors.txt b/tests/baselines/reference/derivedClassWithAny.errors.txt index aa91979706b51..37cb69218f432 100644 --- a/tests/baselines/reference/derivedClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedClassWithAny.errors.txt @@ -1,7 +1,9 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(18,5): error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(19,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(27,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(37,5): error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must provide an initializer with this override. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(38,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(44,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(57,1): error TS2322: Type 'E' is not assignable to type 'C'. @@ -9,7 +11,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit Type 'string' is not assignable to type 'number'. -==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts (7 errors) ==== +==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts (9 errors) ==== class C { x: number; get X(): number { return 1; } @@ -32,6 +34,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit class D extends C { x: any; + ~ +!!! error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. get X(): any { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -55,6 +59,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit // if D is a valid class definition than E is now not safe tranisitively through C class E extends D { x: string; + ~ +!!! error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must provide an initializer with this override. get X(): string{ return ''; } ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt index e63849e4aa887..d7d4167c342e3 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt @@ -1,6 +1,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(10,5): error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(19,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(29,5): error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must provide an initializer with this override. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,18): error TS2322: Type '""' is not assignable to type 'T'. '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. @@ -11,7 +13,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC Type 'string' is not assignable to type 'number'. -==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts (7 errors) ==== +==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts (9 errors) ==== class C { x: T; get X(): T { return null; } @@ -24,6 +26,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC class D extends C { x: any; + ~ +!!! error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. get X(): any { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -47,6 +51,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC // if D is a valid class definition than E is now not safe tranisitively through C class E extends D { x: T; + ~ +!!! error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must provide an initializer with this override. get X(): T { return ''; } // error ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt new file mode 100644 index 0000000000000..0dcdfbee74c89 --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(5,5): error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must provide an initializer with this override. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(11,5): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (2 errors) ==== + class A { + property = 'x'; + } + class B extends A { + property; // should be an error + ~~~~~~~~ +!!! error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must provide an initializer with this override. + } + class C { + p: string; + } + class D extends C { + p: 'hi'; // should also be an error? + ~ +!!! error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. + } + \ No newline at end of file diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js new file mode 100644 index 0000000000000..fbd2f1cdf8ecd --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js @@ -0,0 +1,54 @@ +//// [derivedUninitializedPropertyDeclaration.ts] +class A { + property = 'x'; +} +class B extends A { + property; // should be an error +} +class C { + p: string; +} +class D extends C { + p: 'hi'; // should also be an error? +} + + +//// [derivedUninitializedPropertyDeclaration.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + 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 extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var A = /** @class */ (function () { + function A() { + this.property = 'x'; + } + return A; +}()); +var B = /** @class */ (function (_super) { + __extends(B, _super); + function B() { + return _super !== null && _super.apply(this, arguments) || this; + } + return B; +}(A)); +var C = /** @class */ (function () { + function C() { + } + return C; +}()); +var D = /** @class */ (function (_super) { + __extends(D, _super); + function D() { + return _super !== null && _super.apply(this, arguments) || this; + } + return D; +}(C)); diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols new file mode 100644 index 0000000000000..aad484889bbbd --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts === +class A { +>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) + + property = 'x'; +>property : Symbol(A.property, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 9)) +} +class B extends A { +>B : Symbol(B, Decl(derivedUninitializedPropertyDeclaration.ts, 2, 1)) +>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) + + property; // should be an error +>property : Symbol(B.property, Decl(derivedUninitializedPropertyDeclaration.ts, 3, 19)) +} +class C { +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 5, 1)) + + p: string; +>p : Symbol(C.p, Decl(derivedUninitializedPropertyDeclaration.ts, 6, 9)) +} +class D extends C { +>D : Symbol(D, Decl(derivedUninitializedPropertyDeclaration.ts, 8, 1)) +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 5, 1)) + + p: 'hi'; // should also be an error? +>p : Symbol(D.p, Decl(derivedUninitializedPropertyDeclaration.ts, 9, 19)) +} + diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types new file mode 100644 index 0000000000000..60d8502fb552d --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts === +class A { +>A : A + + property = 'x'; +>property : string +>'x' : "x" +} +class B extends A { +>B : B +>A : A + + property; // should be an error +>property : any +} +class C { +>C : C + + p: string; +>p : string +} +class D extends C { +>D : D +>C : C + + p: 'hi'; // should also be an error? +>p : "hi" +} + diff --git a/tests/baselines/reference/genericPrototypeProperty2.errors.txt b/tests/baselines/reference/genericPrototypeProperty2.errors.txt new file mode 100644 index 0000000000000..212abb8d79552 --- /dev/null +++ b/tests/baselines/reference/genericPrototypeProperty2.errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/genericPrototypeProperty2.ts(7,5): error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must provide an initializer with this override. +tests/cases/compiler/genericPrototypeProperty2.ts(14,5): error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must provide an initializer with this override. + + +==== tests/cases/compiler/genericPrototypeProperty2.ts (2 errors) ==== + interface EventTarget { x } + class BaseEvent { + target: EventTarget; + } + + class MyEvent extends BaseEvent { + target: T; + ~~~~~~ +!!! error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must provide an initializer with this override. + } + class BaseEventWrapper { + t: BaseEvent; + } + + class MyEventWrapper extends BaseEventWrapper { + t: MyEvent; // any satisfies constraint and passes assignability check between 'target' properties + ~ +!!! error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must provide an initializer with this override. + } \ No newline at end of file diff --git a/tests/baselines/reference/genericPrototypeProperty3.errors.txt b/tests/baselines/reference/genericPrototypeProperty3.errors.txt new file mode 100644 index 0000000000000..d13518f48135e --- /dev/null +++ b/tests/baselines/reference/genericPrototypeProperty3.errors.txt @@ -0,0 +1,23 @@ +tests/cases/compiler/genericPrototypeProperty3.ts(6,5): error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must provide an initializer with this override. +tests/cases/compiler/genericPrototypeProperty3.ts(13,5): error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must provide an initializer with this override. + + +==== tests/cases/compiler/genericPrototypeProperty3.ts (2 errors) ==== + class BaseEvent { + target: {}; + } + + class MyEvent extends BaseEvent { // T is instantiated to any in the prototype, which is assignable to {} + target: T; + ~~~~~~ +!!! error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must provide an initializer with this override. + } + class BaseEventWrapper { + t: BaseEvent; + } + + class MyEventWrapper extends BaseEventWrapper { + t: MyEvent; + ~ +!!! error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must provide an initializer with this override. + } \ No newline at end of file diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt index ecb3e4664a470..b4ca2536ac5bd 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt @@ -10,9 +10,10 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte Property 'y' is missing in type 'Bar5' but required in type 'I'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(29,7): error TS2420: Class 'Bar6' incorrectly implements interface 'I'. Property 'y' is protected in type 'Bar6' but public in type 'I'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(38,5): error TS2610: Class 'Foo' defines instance member property 'x', so extended class 'Bar8' must provide an initializer with this override. -==== tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts (6 errors) ==== +==== tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts (7 errors) ==== class Foo { protected x: string; } @@ -71,6 +72,8 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte class Bar8 extends Foo implements I { x: string; + ~ +!!! error TS2610: Class 'Foo' defines instance member property 'x', so extended class 'Bar8' must provide an initializer with this override. y: number; } \ No newline at end of file diff --git a/tests/baselines/reference/inheritance.errors.txt b/tests/baselines/reference/inheritance.errors.txt index b476f1399b445..12994b1c87665 100644 --- a/tests/baselines/reference/inheritance.errors.txt +++ b/tests/baselines/reference/inheritance.errors.txt @@ -1,9 +1,10 @@ +tests/cases/compiler/inheritance.ts(22,12): error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must provide an initializer with this override. 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 'Good'. Type '(n: number) => number' is not assignable to type '() => number'. -==== tests/cases/compiler/inheritance.ts (2 errors) ==== +==== tests/cases/compiler/inheritance.ts (3 errors) ==== class B1 { public x; } @@ -26,6 +27,8 @@ tests/cases/compiler/inheritance.ts(32,12): error TS2416: Property 'g' in type ' class ND extends N { // any is assignable to number public y; + ~ +!!! error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must provide an initializer with this override. } class Good { diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt index ec8ec05a8aeb5..9491f47ff133b 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(6,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(12,5): error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must provide an initializer with this override. -==== tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts (2 errors) ==== +==== tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts (3 errors) ==== class a { private __x: () => string; get x() { @@ -19,4 +20,6 @@ tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(6,9): error class b extends a { x: () => string; + ~ +!!! error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must provide an initializer with this override. } \ No newline at end of file diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt new file mode 100644 index 0000000000000..ed604c5260725 --- /dev/null +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts(6,5): error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must provide an initializer with this override. + + +==== tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts (1 errors) ==== + class a { + x: () => string; + } + + class b extends a { + x: () => string; + ~ +!!! error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must provide an initializer with this override. + } \ No newline at end of file diff --git a/tests/baselines/reference/instanceSubtypeCheck2.errors.txt b/tests/baselines/reference/instanceSubtypeCheck2.errors.txt index 84b454d7ea0a6..cd53a1304c246 100644 --- a/tests/baselines/reference/instanceSubtypeCheck2.errors.txt +++ b/tests/baselines/reference/instanceSubtypeCheck2.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2416: Property 'x' in type 'C2' is not assignable to the same property in base type 'C1'. Type 'string' is not assignable to type 'C2'. +tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2610: Class 'C1' defines instance member property 'x', so extended class 'C2' must provide an initializer with this override. -==== tests/cases/compiler/instanceSubtypeCheck2.ts (1 errors) ==== +==== tests/cases/compiler/instanceSubtypeCheck2.ts (2 errors) ==== class C1 { x: C2; } @@ -12,4 +13,6 @@ tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2416: Property 'x' i ~ !!! error TS2416: Property 'x' in type 'C2' is not assignable to the same property in base type 'C1'. !!! error TS2416: Type 'string' is not assignable to type 'C2'. + ~ +!!! error TS2610: Class 'C1' defines instance member property 'x', so extended class 'C2' must provide an initializer with this override. } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt new file mode 100644 index 0000000000000..a200f3bffe1e4 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt @@ -0,0 +1,78 @@ +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(20,38): error TS2610: Class 'I1' defines instance member property 'x', so extended class 'C1' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(21,38): error TS2610: Class 'I2' defines instance member property 'x', so extended class 'C2' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(22,38): error TS2610: Class 'I3' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(23,38): error TS2610: Class 'I4' defines instance member property 'x', so extended class 'C4' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(24,38): error TS2610: Class 'I5' defines instance member property 'x', so extended class 'C5' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(25,38): error TS2610: Class 'I6' defines instance member property 'x', so extended class 'C6' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(26,38): error TS2610: Class 'I7' defines instance member property 'x', so extended class 'C7' must provide an initializer with this override. + + +==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts (7 errors) ==== + type T1 = { a: number }; + type T2 = T1 & { b: number }; + type T3 = () => void; + type T4 = new () => { a: number }; + type T5 = number[]; + type T6 = [string, number]; + type T7 = { [P in 'a' | 'b' | 'c']: string }; + + interface I1 extends T1 { x: string } + interface I2 extends T2 { x: string } + interface I3 extends T3 { x: string } + interface I4 extends T4 { x: string } + interface I5 extends T5 { x: string } + interface I6 extends T6 { x: string } + interface I7 extends T7 { x: string } + + type Constructor = new () => T; + declare function Constructor(): Constructor; + + class C1 extends Constructor() { x: string } + ~ +!!! error TS2610: Class 'I1' defines instance member property 'x', so extended class 'C1' must provide an initializer with this override. + class C2 extends Constructor() { x: string } + ~ +!!! error TS2610: Class 'I2' defines instance member property 'x', so extended class 'C2' must provide an initializer with this override. + class C3 extends Constructor() { x: string } + ~ +!!! error TS2610: Class 'I3' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. + class C4 extends Constructor() { x: string } + ~ +!!! error TS2610: Class 'I4' defines instance member property 'x', so extended class 'C4' must provide an initializer with this override. + class C5 extends Constructor() { x: string } + ~ +!!! error TS2610: Class 'I5' defines instance member property 'x', so extended class 'C5' must provide an initializer with this override. + class C6 extends Constructor() { x: string } + ~ +!!! error TS2610: Class 'I6' defines instance member property 'x', so extended class 'C6' must provide an initializer with this override. + class C7 extends Constructor() { x: string } + ~ +!!! error TS2610: Class 'I7' defines instance member property 'x', so extended class 'C7' must provide an initializer with this override. + + declare function fx(x: string): string; + declare class CX { a: number } + declare enum EX { A, B, C } + declare namespace NX { export const a = 1 } + + type T10 = typeof fx; + type T11 = typeof CX; + type T12 = typeof EX; + type T13 = typeof NX; + + interface I10 extends T10 { x: string } + interface I11 extends T11 { x: string } + interface I12 extends T12 { x: string } + interface I13 extends T13 { x: string } + + type Identifiable = { _id: string } & T; + + interface I20 extends Partial { x: string } + interface I21 extends Readonly { x: string } + interface I22 extends Identifiable { x: string } + interface I23 extends Identifiable { x: string } + + class C20 extends Constructor>() { x: string } + class C21 extends Constructor>() { x: string } + class C22 extends Constructor>() { x: string } + class C23 extends Constructor>() { x: string } + \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt index 17cb5585cf87e..9acd77695b67d 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt @@ -16,14 +16,19 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI 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 'T1'. Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(16,38): error TS2610: Class 'T1' defines instance member property 'a', so extended class 'C1' must provide an initializer with this override. 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 'T2'. Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,38): error TS2610: Class 'T2' defines instance member property 'b', so extended class 'C2' must provide an initializer with this override. 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(18,38): error TS2610: Class 'number[]' defines instance member property 'length', so extended class 'C3' must provide an initializer with this override. 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, number]'. Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,38): error TS2610: Class '[string, number]' defines instance member property '0', so extended class 'C4' must provide an initializer with this override. 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 'T5'. Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(20,38): error TS2610: Class 'T5' defines instance member property 'c', so extended class 'C5' must provide an initializer with this override. 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'. @@ -55,7 +60,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(47,26): error TS2312: An interface can only extend an object type or intersection of object types with statically known members. -==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts (23 errors) ==== +==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts (28 errors) ==== type T1 = { a: number }; type T2 = T1 & { b: number }; type T3 = number[]; @@ -96,22 +101,32 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI ~ !!! error TS2416: Property 'a' in type 'C1' is not assignable to the same property in base type 'T1'. !!! error TS2416: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2610: Class 'T1' defines instance member property 'a', so extended class 'C1' must provide an initializer with this override. class C2 extends Constructor() { b: string } ~ !!! error TS2416: Property 'b' in type 'C2' is not assignable to the same property in base type 'T2'. !!! error TS2416: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2610: Class 'T2' defines instance member property 'b', so extended class 'C2' must provide an initializer with this override. class C3 extends Constructor() { length: string } ~~~~~~ !!! 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'. + ~~~~~~ +!!! error TS2610: Class 'number[]' defines instance member property 'length', so extended class 'C3' must provide an initializer with this override. class C4 extends Constructor() { 0: number } ~ !!! error TS2416: Property '0' in type 'C4' is not assignable to the same property in base type '[string, number]'. !!! error TS2416: Type 'number' is not assignable to type 'string'. + ~ +!!! error TS2610: Class '[string, number]' defines instance member property '0', so extended class 'C4' must provide an initializer with this override. class C5 extends Constructor() { c: number } ~ !!! error TS2416: Property 'c' in type 'C5' is not assignable to the same property in base type 'T5'. !!! error TS2416: Type 'number' is not assignable to type 'string'. + ~ +!!! error TS2610: Class 'T5' defines instance member property 'c', so extended class 'C5' must provide an initializer with this override. declare class CX { static a: string } declare enum EX { A, B, C } diff --git a/tests/baselines/reference/multipleInheritance.errors.txt b/tests/baselines/reference/multipleInheritance.errors.txt index c4a440d9a0ea5..b3e6a02c72942 100644 --- a/tests/baselines/reference/multipleInheritance.errors.txt +++ b/tests/baselines/reference/multipleInheritance.errors.txt @@ -1,11 +1,12 @@ 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(26,12): error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must provide an initializer with this override. 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 'Good'. Type '(n: number) => number' is not assignable to type '() => number'. -==== tests/cases/compiler/multipleInheritance.ts (4 errors) ==== +==== tests/cases/compiler/multipleInheritance.ts (5 errors) ==== class B1 { public x; } @@ -36,6 +37,8 @@ tests/cases/compiler/multipleInheritance.ts(36,12): error TS2416: Property 'g' i class ND extends N { // any is assignable to number public y; + ~ +!!! error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must provide an initializer with this override. } class Good { diff --git a/tests/baselines/reference/mutuallyRecursiveInference.errors.txt b/tests/baselines/reference/mutuallyRecursiveInference.errors.txt new file mode 100644 index 0000000000000..9f5b1852c7c47 --- /dev/null +++ b/tests/baselines/reference/mutuallyRecursiveInference.errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/mutuallyRecursiveInference.ts(9,5): error TS2610: Class 'L' defines instance member property 'a', so extended class 'X' must provide an initializer with this override. +tests/cases/compiler/mutuallyRecursiveInference.ts(10,5): error TS2610: Class 'L' defines instance member property 'b', so extended class 'X' must provide an initializer with this override. + + +==== tests/cases/compiler/mutuallyRecursiveInference.ts (2 errors) ==== + class T { + a: A; + b: any + } + class L extends T { + m() { this.a } + } + class X extends L { + a: 'a' | 'b' + ~ +!!! error TS2610: Class 'L' defines instance member property 'a', so extended class 'X' must provide an initializer with this override. + b: number + ~ +!!! error TS2610: Class 'L' defines instance member property 'b', so extended class 'X' must provide an initializer with this override. + m2() { + this.a + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/protectedMembers.errors.txt b/tests/baselines/reference/protectedMembers.errors.txt index 9171df2a485b6..5a1fc2bfeb351 100644 --- a/tests/baselines/reference/protectedMembers.errors.txt +++ b/tests/baselines/reference/protectedMembers.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/protectedMembers.ts(25,5): error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. tests/cases/compiler/protectedMembers.ts(40,4): error TS2445: Property 'x' is protected and only accessible within class 'C1' and its subclasses. tests/cases/compiler/protectedMembers.ts(41,4): error TS2445: Property 'f' is protected and only accessible within class 'C1' and its subclasses. tests/cases/compiler/protectedMembers.ts(42,4): error TS2445: Property 'sx' is protected and only accessible within class 'C1' and its subclasses. @@ -12,11 +13,13 @@ tests/cases/compiler/protectedMembers.ts(97,1): error TS2322: Type 'B1' is not a Property 'x' is protected but type 'B1' is not a class derived from 'A1'. tests/cases/compiler/protectedMembers.ts(98,1): error TS2322: Type 'A1' is not assignable to type 'B1'. Property 'x' is protected in type 'A1' but public in type 'B1'. +tests/cases/compiler/protectedMembers.ts(104,5): error TS2610: Class 'A2' defines instance member property 'x', so extended class 'B2' must provide an initializer with this override. tests/cases/compiler/protectedMembers.ts(111,7): error TS2415: Class 'B3' incorrectly extends base class 'A3'. Property 'x' is protected in type 'B3' but public in type 'A3'. +tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Class 'A3' defines instance member property 'x', so extended class 'B3' must provide an initializer with this override. -==== tests/cases/compiler/protectedMembers.ts (13 errors) ==== +==== tests/cases/compiler/protectedMembers.ts (16 errors) ==== // Class with protected members class C1 { protected x: number; @@ -42,6 +45,8 @@ tests/cases/compiler/protectedMembers.ts(111,7): error TS2415: Class 'B3' incorr // Derived class making protected members public class C3 extends C2 { x: number; + ~ +!!! error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. static sx: number; f() { return super.f(); @@ -147,6 +152,8 @@ tests/cases/compiler/protectedMembers.ts(111,7): error TS2415: Class 'B3' incorr } class B2 extends A2 { x; + ~ +!!! error TS2610: Class 'A2' defines instance member property 'x', so extended class 'B2' must provide an initializer with this override. } class A3 { @@ -158,6 +165,8 @@ tests/cases/compiler/protectedMembers.ts(111,7): error TS2415: Class 'B3' incorr !!! error TS2415: Class 'B3' incorrectly extends base class 'A3'. !!! error TS2415: Property 'x' is protected in type 'B3' but public in type 'A3'. protected x; + ~ +!!! error TS2610: Class 'A3' defines instance member property 'x', so extended class 'B3' must provide an initializer with this override. } \ No newline at end of file diff --git a/tests/baselines/reference/scopeTests.errors.txt b/tests/baselines/reference/scopeTests.errors.txt index ce24301efc2bf..2457ba3912a61 100644 --- a/tests/baselines/reference/scopeTests.errors.txt +++ b/tests/baselines/reference/scopeTests.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/scopeTests.ts(2,7): error TS2415: Class 'D' incorrectly extends base class 'C'. Property 'v' is private in type 'C' but not in type 'D'. +tests/cases/compiler/scopeTests.ts(4,10): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. -==== tests/cases/compiler/scopeTests.ts (1 errors) ==== +==== tests/cases/compiler/scopeTests.ts (2 errors) ==== class C { private v; public p; static s; } class D extends C { ~ @@ -10,6 +11,8 @@ tests/cases/compiler/scopeTests.ts(2,7): error TS2415: Class 'D' incorrectly ext !!! error TS2415: Property 'v' is private in type 'C' but not in type 'D'. public v: number; public p: number + ~ +!!! error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. constructor() { super() this.v = 1; diff --git a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt index 0ec8951fe9391..4541037baae14 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt @@ -1,9 +1,10 @@ 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 'C3'. Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(8,5): error TS2610: Class 'C3' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. -==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (1 errors) ==== +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (2 errors) ==== // checking whether other types are subtypes of type parameters class C3 { @@ -16,6 +17,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D1' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + ~~~ +!!! error TS2610: Class 'C3' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. } function f1(x: T, y: U) { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index 03656c08c4ef2..e952bf31059ee 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt @@ -1,27 +1,36 @@ +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(37,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(42,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. 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(47,5): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'B1'. Type 'V' is not assignable to type 'Foo'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(52,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. 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(57,5): error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'B1'. Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. Type 'Foo' is not assignable to type 'T'. 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. 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(62,5): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'B1'. Type 'V' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. 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(67,5): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'B1'. Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. Type 'Foo' is not assignable to type 'U'. 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(72,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. 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'. 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 'B1'. Type 'V' is not assignable to type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. -==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (10 errors) ==== +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (19 errors) ==== // checking whether other types are subtypes of type parameters with constraints class Foo { foo: number; } @@ -59,11 +68,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf class D1 extends B1 { [x: string]: Foo; foo: T; // ok + ~~~ +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. } class D2 extends B1 { [x: string]: Foo; foo: U; // ok + ~~~ +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. } class D3 extends B1 { @@ -74,11 +87,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'V' is not assignable to type 'Foo'. + ~~~ +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. } class D4 extends B1 { [x: string]: T; foo: T; // ok + ~~~ +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. } class D5 extends B1 { @@ -92,6 +109,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. !!! error TS2416: Type 'Foo' is not assignable to type 'T'. !!! error TS2416: 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. + ~~~ +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. } class D6 extends B1 { @@ -102,6 +121,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'V' is not assignable to type 'T'. + ~~~ +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. } class D7 extends B1 { @@ -115,11 +136,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. !!! error TS2416: Type 'Foo' is not assignable to type 'U'. !!! error TS2416: 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. + ~~~ +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. } class D8 extends B1 { [x: string]: U; foo: U; // ok + ~~~ +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. } class D9 extends B1 { @@ -130,4 +155,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2416: Property 'foo' in type 'D9' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'V' is not assignable to type 'U'. + ~~~ +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt index 700076db4d190..4247c68cb876a 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt @@ -1,66 +1,84 @@ +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(63,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. 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(68,9): error TS2416: Property 'foo' in type 'D2' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. 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(73,9): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. 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(78,9): error TS2416: Property 'foo' in type 'D4' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(83,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. 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(88,9): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. 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(93,9): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. 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(98,9): error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(103,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. 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 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. 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(120,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. 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(125,9): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. 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(130,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. 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 'Base2'. 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(135,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. 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(140,9): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. 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(145,9): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. 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'. 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 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(155,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. -==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (24 errors) ==== +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (42 errors) ==== // checking whether other types are subtypes of type parameters with constraints class Foo { foo: T; } @@ -124,6 +142,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf class D1, U extends Foo, V extends Foo> extends Base { [x: string]: T; foo: T + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. } class D2, U extends Foo, V extends Foo> extends Base { @@ -135,6 +155,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D2' is not assignable to the same property in base type 'Base'. !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: Type 'Foo' is not assignable to type 'T'. + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. } class D3, U extends Foo, V extends Foo> extends Base { @@ -146,6 +168,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Base'. !!! error TS2416: Type 'V' is not assignable to type 'T'. !!! error TS2416: Type 'Foo' is not assignable to type 'T'. + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. } class D4, U extends Foo, V extends Foo> extends Base { @@ -157,11 +181,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D4' is not assignable to the same property in base type 'Base'. !!! error TS2416: Type 'T' is not assignable to type 'U'. !!! error TS2416: Type 'Foo' is not assignable to type 'U'. + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. } class D5, U extends Foo, V extends Foo> extends Base { [x: string]: U; foo: U + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. } class D6, U extends Foo, V extends Foo> extends Base { @@ -173,6 +201,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Base'. !!! error TS2416: Type 'V' is not assignable to type 'U'. !!! error TS2416: Type 'Foo' is not assignable to type 'U'. + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. } class D7, U extends Foo, V extends Foo> extends Base { @@ -184,6 +214,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'Base'. !!! error TS2416: Type 'T' is not assignable to type 'V'. !!! error TS2416: Type 'Foo' is not assignable to type 'V'. + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. } class D8, U extends Foo, V extends Foo> extends Base { @@ -195,11 +227,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'Base'. !!! error TS2416: Type 'U' is not assignable to type 'V'. !!! error TS2416: Type 'Foo' is not assignable to type 'V'. + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. } class D9, U extends Foo, V extends Foo> extends Base { [x: string]: V; foo: V + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. } } @@ -218,6 +254,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! 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'. + ~~~ +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. } class D2, U extends Foo, V extends Foo> extends Base2 { @@ -225,6 +263,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf foo: U ~~~ !!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. + ~~~ +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. } class D3, U extends Foo, V extends Foo> extends Base2 { @@ -238,6 +278,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. } class D4, U extends Foo, V extends Foo> extends Base2 { @@ -245,6 +287,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf foo: T ~~~ !!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. + ~~~ +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. } class D5, U extends Foo, V extends Foo> extends Base2 { @@ -256,6 +300,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! 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'. + ~~~ +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. } class D6, U extends Foo, V extends Foo> extends Base2 { @@ -269,6 +315,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. } class D7, U extends Foo, V extends Foo> extends Base2 { @@ -282,6 +330,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. } class D8, U extends Foo, V extends Foo> extends Base2 { @@ -295,10 +345,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. } class D9, U extends Foo, V extends Foo> extends Base2 { [x: string]: V; foo: V + ~~~ +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. } } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingTransitivity.errors.txt b/tests/baselines/reference/subtypingTransitivity.errors.txt new file mode 100644 index 0000000000000..1284422452565 --- /dev/null +++ b/tests/baselines/reference/subtypingTransitivity.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/subtypingTransitivity.ts(6,12): error TS2610: Class 'B' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. +tests/cases/compiler/subtypingTransitivity.ts(9,12): error TS2610: Class 'B' defines instance member property 'x', so extended class 'D2' must provide an initializer with this override. + + +==== tests/cases/compiler/subtypingTransitivity.ts (2 errors) ==== + class B { + x: Object; + } + + class D extends B { + public x: string; + ~ +!!! error TS2610: Class 'B' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. + } + class D2 extends B { + public x: number; + ~ +!!! error TS2610: Class 'B' defines instance member property 'x', so extended class 'D2' must provide an initializer with this override. + } + + var b: B; + var d: D; + var d2: D2; + + d.x = ''; + b = d; + b.x = 1; // assigned number to string + \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithObjectMembers.errors.txt b/tests/baselines/reference/subtypingWithObjectMembers.errors.txt index 1e2f7bc9114f1..6690c442c81a7 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers.errors.txt +++ b/tests/baselines/reference/subtypingWithObjectMembers.errors.txt @@ -1,18 +1,30 @@ +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(13,5): error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must provide an initializer with this override. 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 'A'. Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(14,5): error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(23,5): error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must provide an initializer with this override. 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 'A2'. Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(24,5): error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(33,5): error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must provide an initializer with this override. 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 'A3'. Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(34,5): error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(44,9): error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must provide an initializer with this override. 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 'A'. Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(45,9): error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(54,9): error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must provide an initializer with this override. 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 'A2'. Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(55,9): error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(64,9): error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must provide an initializer with this override. 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 'A3'. Type 'string' is not assignable to type 'Base'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(65,9): error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must provide an initializer with this override. -==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts (6 errors) ==== +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts (18 errors) ==== class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } @@ -26,10 +38,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { foo: Derived; // ok + ~~~ +!!! error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must provide an initializer with this override. bar: string; // error ~~~ !!! error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'A'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. + ~~~ +!!! error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must provide an initializer with this override. } class A2 { @@ -39,10 +55,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B2 extends A2 { 1: Derived; // ok + ~ +!!! error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must provide an initializer with this override. 2: string; // error ~ !!! error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'A2'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. + ~ +!!! error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must provide an initializer with this override. } class A3 { @@ -52,10 +72,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A3 { '1': Derived; // ok + ~~~ +!!! error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must provide an initializer with this override. '2.0': string; // error ~~~~~ !!! error TS2416: Property ''2.0'' in type 'B3' is not assignable to the same property in base type 'A3'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. + ~~~~~ +!!! error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must provide an initializer with this override. } module TwoLevels { @@ -66,10 +90,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { foo: Derived2; // ok + ~~~ +!!! error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must provide an initializer with this override. bar: string; // error ~~~ !!! error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'A'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. + ~~~ +!!! error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must provide an initializer with this override. } class A2 { @@ -79,10 +107,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B2 extends A2 { 1: Derived2; // ok + ~ +!!! error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must provide an initializer with this override. 2: string; // error ~ !!! error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'A2'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. + ~ +!!! error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must provide an initializer with this override. } class A3 { @@ -92,9 +124,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A3 { '1': Derived2; // ok + ~~~ +!!! error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must provide an initializer with this override. '2.0': string; // error ~~~~~ !!! error TS2416: Property ''2.0'' in type 'B3' is not assignable to the same property in base type 'A3'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. + ~~~~~ +!!! error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must provide an initializer with this override. } } \ No newline at end of file diff --git a/tests/baselines/reference/tsxGenericAttributesType5.errors.txt b/tests/baselines/reference/tsxGenericAttributesType5.errors.txt new file mode 100644 index 0000000000000..42f10f91f7fa2 --- /dev/null +++ b/tests/baselines/reference/tsxGenericAttributesType5.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must provide an initializer with this override. + + +==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== + import React = require('react'); + + class B1 extends React.Component { + render() { + return
hi
; + } + } + class B extends React.Component { + props: U; + ~~~~~ +!!! error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must provide an initializer with this override. + render() { + return ; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/tsxGenericAttributesType6.errors.txt b/tests/baselines/reference/tsxGenericAttributesType6.errors.txt new file mode 100644 index 0000000000000..af26e4a25b933 --- /dev/null +++ b/tests/baselines/reference/tsxGenericAttributesType6.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must provide an initializer with this override. + + +==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== + import React = require('react'); + + class B1 extends React.Component { + render() { + return
hi
; + } + } + class B extends React.Component { + props: U; + ~~~~~ +!!! error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must provide an initializer with this override. + render() { + return ; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt b/tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt new file mode 100644 index 0000000000000..2bba64a42e2c6 --- /dev/null +++ b/tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt @@ -0,0 +1,190 @@ +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(8,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D0' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(12,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'DA' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(16,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(20,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1A' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(25,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(29,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2A' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(34,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(38,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3A' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(43,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(47,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(52,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(56,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(61,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(68,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(73,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D10' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(78,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D11' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(86,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D12' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(95,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D13' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(100,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D14' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(105,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D15' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(114,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D16' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(119,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D17' must provide an initializer with this override. + + +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts (22 errors) ==== + // undefined is a subtype of every other types, no errors expected below + + class Base { + foo: typeof undefined; + } + + class D0 extends Base { + foo: any; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D0' must provide an initializer with this override. + } + + class DA extends Base { + foo: typeof undefined; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'DA' must provide an initializer with this override. + } + + class D1 extends Base { + foo: string; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. + } + + class D1A extends Base { + foo: String; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1A' must provide an initializer with this override. + } + + + class D2 extends Base { + foo: number; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. + } + + class D2A extends Base { + foo: Number; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2A' must provide an initializer with this override. + } + + + class D3 extends Base { + foo: boolean; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. + } + + class D3A extends Base { + foo: Boolean; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3A' must provide an initializer with this override. + } + + + class D4 extends Base { + foo: RegExp; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. + } + + class D5 extends Base { + foo: Date; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. + } + + + class D6 extends Base { + foo: number[]; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. + } + + class D7 extends Base { + foo: { bar: number }; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. + } + + + class D8 extends Base { + foo: D7; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. + } + + interface I1 { + bar: string; + } + class D9 extends Base { + foo: I1; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. + } + + + class D10 extends Base { + foo: () => number; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D10' must provide an initializer with this override. + } + + enum E { A } + class D11 extends Base { + foo: E; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D11' must provide an initializer with this override. + } + + function f() { } + module f { + export var bar = 1; + } + class D12 extends Base { + foo: typeof f; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D12' must provide an initializer with this override. + } + + + class c { baz: string } + module c { + export var bar = 1; + } + class D13 extends Base { + foo: typeof c; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D13' must provide an initializer with this override. + } + + + class D14 extends Base { + foo: T; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D14' must provide an initializer with this override. + } + + + class D15 extends Base { + foo: U; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D15' must provide an initializer with this override. + } + + //class D15 extends Base { + // foo: U; + //} + + + class D16 extends Base { + foo: Object; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D16' must provide an initializer with this override. + } + + + class D17 extends Base { + foo: {}; + ~~~ +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D17' must provide an initializer with this override. + } + \ No newline at end of file diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts new file mode 100644 index 0000000000000..8dbaed41b10de --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts @@ -0,0 +1,12 @@ +class A { + property = 'x'; +} +class B extends A { + property; // should be an error +} +class C { + p: string; +} +class D extends C { + p: 'hi'; // should also be an error? +} diff --git a/tests/cases/fourslash/incompatibleOverride.ts b/tests/cases/fourslash/incompatibleOverride.ts index 0b3dd3230154c..1ce0b07def189 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 Bar extends Foo { /*1*/xyz/*2*/: number; } -//// class Baz extends Foo { public /*3*/xyz/*4*/: number; } +//// class Bar extends Foo { /*1*/xyz/*2*/: number = 1; } +//// class Baz extends Foo { public /*3*/xyz/*4*/: number = 2; } //// class /*5*/Baf/*6*/ extends Foo { //// constructor(public xyz: number) { //// super(); @@ -14,4 +14,4 @@ verify.errorExistsBetweenMarkers('1', '2'); verify.errorExistsBetweenMarkers('3', '4'); verify.errorExistsBetweenMarkers('5', '6'); -verify.numberOfErrorsInCurrentFile(3); \ No newline at end of file +verify.numberOfErrorsInCurrentFile(3); diff --git a/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts b/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts index 955d461b9f13a..c97c6c75fcf5b 100644 --- a/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts +++ b/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts @@ -5,8 +5,8 @@ ////} //// ////class Bar extends Foo { -//// public /*1*/x/*2*/: string; +//// public /*1*/x/*2*/: string = 'hi'; ////} verify.errorExistsBetweenMarkers("1", "2"); -verify.numberOfErrorsInCurrentFile(1); \ No newline at end of file +verify.numberOfErrorsInCurrentFile(1); From 70a15bdeeb432e77bc62ee9e2ffd378922da3c3f Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 16 Sep 2019 10:56:30 -0700 Subject: [PATCH 02/17] Need to add a couple of errors and squash one Will update after checking out other branch for a minute --- src/compiler/checker.ts | 11 ++++++-- ...ninitializedPropertyDeclaration.errors.txt | 12 ++++++-- ...derivedUninitializedPropertyDeclaration.js | 24 ++++++++++++++-- ...edUninitializedPropertyDeclaration.symbols | 28 ++++++++++++++----- ...ivedUninitializedPropertyDeclaration.types | 18 ++++++++++-- ...derivedUninitializedPropertyDeclaration.ts | 21 ++++++++++++-- 6 files changed, 95 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 311b57d1c1701..84b34fcd84a57 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29477,7 +29477,6 @@ namespace ts { // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { // derived class inherits base without override/redeclaration - const derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol)!; // It is an error to inherit an abstract member without implementing it or being declared abstract. @@ -29522,6 +29521,7 @@ namespace ts { if (derived.flags & SymbolFlags.Property && !(derived.flags & SymbolFlags.Transient) && !(baseDeclarationFlags & ModifierFlags.Abstract) + && !(derivedDeclarationFlags & ModifierFlags.Ambient) && !derived.declarations.some(d => d.flags & NodeFlags.Ambient) && derived.declarations.some(d => d.kind === SyntaxKind.PropertyDeclaration && !(d as PropertyDeclaration).initializer)) { const errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_so_extended_class_2_must_provide_an_initializer_with_this_override; @@ -29529,6 +29529,11 @@ namespace ts { } continue; } + if (derivedDeclarationFlags & ModifiersFlags.Ambient) { + const errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_so_extended_class_2_must_provide_an_initializer_with_this_override; + error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + continue; + } let errorMessage: DiagnosticMessage; if (isPrototypeProperty(base)) { @@ -32518,7 +32523,7 @@ namespace ts { else if (flags & ModifierFlags.Async) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (isClassLike(node.parent)) { + else if (isClassLike(node.parent) && !isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === SyntaxKind.Parameter) { @@ -33627,7 +33632,7 @@ namespace ts { } } - if (node.flags & NodeFlags.Ambient) { + if (node.flags & NodeFlags.Ambient || getModifierFlags(node) & ModifierFlags.Ambient) { checkAmbientInitializer(node); } diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt index 0dcdfbee74c89..7da5e3b68acce 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(5,5): error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must provide an initializer with this override. -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(11,5): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(14,5): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. ==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (2 errors) ==== @@ -7,16 +7,22 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP property = 'x'; } class B extends A { - property; // should be an error + property; // error ~~~~~~~~ !!! error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must provide an initializer with this override. } + class BD extends A { + declare property; // still has implicit any + } class C { p: string; } class D extends C { - p: 'hi'; // should also be an error? + p: 'hi'; // error ~ !!! error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. } + class DD extends C { + declare p: 'bye'; // ok + } \ No newline at end of file diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js index fbd2f1cdf8ecd..748c143279e34 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js @@ -3,13 +3,19 @@ class A { property = 'x'; } class B extends A { - property; // should be an error + property; // error +} +class BD extends A { + declare property; // still has implicit any } class C { p: string; } class D extends C { - p: 'hi'; // should also be an error? + p: 'hi'; // error +} +class DD extends C { + declare p: 'bye'; // ok } @@ -40,6 +46,13 @@ var B = /** @class */ (function (_super) { } return B; }(A)); +var BD = /** @class */ (function (_super) { + __extends(BD, _super); + function BD() { + return _super !== null && _super.apply(this, arguments) || this; + } + return BD; +}(A)); var C = /** @class */ (function () { function C() { } @@ -52,3 +65,10 @@ var D = /** @class */ (function (_super) { } return D; }(C)); +var DD = /** @class */ (function (_super) { + __extends(DD, _super); + function DD() { + return _super !== null && _super.apply(this, arguments) || this; + } + return DD; +}(C)); diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols index aad484889bbbd..f18c1602880d6 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols @@ -9,20 +9,34 @@ class B extends A { >B : Symbol(B, Decl(derivedUninitializedPropertyDeclaration.ts, 2, 1)) >A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) - property; // should be an error + property; // error >property : Symbol(B.property, Decl(derivedUninitializedPropertyDeclaration.ts, 3, 19)) } +class BD extends A { +>BD : Symbol(BD, Decl(derivedUninitializedPropertyDeclaration.ts, 5, 1)) +>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) + + declare property; // still has implicit any +>property : Symbol(BD.property, Decl(derivedUninitializedPropertyDeclaration.ts, 6, 20)) +} class C { ->C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 5, 1)) +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 8, 1)) p: string; ->p : Symbol(C.p, Decl(derivedUninitializedPropertyDeclaration.ts, 6, 9)) +>p : Symbol(C.p, Decl(derivedUninitializedPropertyDeclaration.ts, 9, 9)) } class D extends C { ->D : Symbol(D, Decl(derivedUninitializedPropertyDeclaration.ts, 8, 1)) ->C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 5, 1)) +>D : Symbol(D, Decl(derivedUninitializedPropertyDeclaration.ts, 11, 1)) +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 8, 1)) + + p: 'hi'; // error +>p : Symbol(D.p, Decl(derivedUninitializedPropertyDeclaration.ts, 12, 19)) +} +class DD extends C { +>DD : Symbol(DD, Decl(derivedUninitializedPropertyDeclaration.ts, 14, 1)) +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 8, 1)) - p: 'hi'; // should also be an error? ->p : Symbol(D.p, Decl(derivedUninitializedPropertyDeclaration.ts, 9, 19)) + declare p: 'bye'; // ok +>p : Symbol(DD.p, Decl(derivedUninitializedPropertyDeclaration.ts, 15, 20)) } diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types index 60d8502fb552d..693cc0dcd288e 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types @@ -10,7 +10,14 @@ class B extends A { >B : B >A : A - property; // should be an error + property; // error +>property : any +} +class BD extends A { +>BD : BD +>A : A + + declare property; // still has implicit any >property : any } class C { @@ -23,7 +30,14 @@ class D extends C { >D : D >C : C - p: 'hi'; // should also be an error? + p: 'hi'; // error >p : "hi" } +class DD extends C { +>DD : DD +>C : C + + declare p: 'bye'; // ok +>p : "bye" +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts index 8dbaed41b10de..8988576b4f3e5 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts @@ -1,12 +1,29 @@ +// @strict: true class A { property = 'x'; + m() { return 1 } } class B extends A { - property; // should be an error + property; // error } +class BD extends A { + declare property; // still has implicit any, but is implicitly initialised +} +class BDBang extends A { + declare property!; // still has implicit any, doesn't need !, but has it anyway +} +class BOther extends A { + declare m() { return 2 } // not allowed on methods + declare nonce; // only allowed when exists in base + declare property = 'y' // initialiser not allowed with declare +} + class C { p: string; } class D extends C { - p: 'hi'; // should also be an error? + p: 'hi'; // error +} +class DD extends C { + declare p: 'bye'; // ok } From feb0fb6dc4c3e4b93af9f07f1f57275f80fe61cc Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 16 Sep 2019 13:36:04 -0700 Subject: [PATCH 03/17] Everything works so far Need to test properties initialised in constructor --- src/compiler/checker.ts | 36 ++++++--- src/compiler/diagnosticMessages.json | 4 + ...lassExpressionPropertyModifiers.errors.txt | 11 ++- ...ninitializedPropertyDeclaration.errors.txt | 54 +++++++++++-- ...derivedUninitializedPropertyDeclaration.js | 58 +++++++++++++- ...edUninitializedPropertyDeclaration.symbols | 79 +++++++++++++++---- ...ivedUninitializedPropertyDeclaration.types | 58 +++++++++++++- ...illegalModifiersOnClassElements.errors.txt | 11 ++- ...rserMemberAccessorDeclaration11.errors.txt | 5 +- ...arserMemberFunctionDeclaration5.errors.txt | 5 +- ...arserMemberVariableDeclaration5.errors.txt | 6 +- ...derivedUninitializedPropertyDeclaration.ts | 21 ++++- 12 files changed, 297 insertions(+), 51 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 84b34fcd84a57..bf614c2068568 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29206,6 +29206,11 @@ namespace ts { } } + function getClassOrInterfaceDeclarationsOfSymbol(symbol: Symbol) { + return filter(symbol.declarations, (d: Declaration): d is ClassDeclaration | InterfaceDeclaration => + d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.InterfaceDeclaration); + } + function areTypeParametersIdentical(declarations: readonly (ClassDeclaration | InterfaceDeclaration)[], targetParameters: TypeParameter[]) { const maxTypeArgumentCount = length(targetParameters); const minTypeArgumentCount = getMinTypeArgumentCount(targetParameters); @@ -29299,6 +29304,7 @@ namespace ts { checkClassForStaticPropertyNameConflicts(node); } + let baseType: BaseType | undefined; const baseTypeNode = getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < ScriptTarget.ES2015) { @@ -29312,7 +29318,7 @@ namespace ts { const baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { - const baseType = baseTypes[0]; + baseType = baseTypes[0]; const baseConstructorType = getBaseConstructorTypeOfClass(type); const staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); @@ -29352,6 +29358,7 @@ namespace ts { checkKindsOfPropertyMemberOverrides(type, baseType); } } + checkAmbientPropertyMemberOverrides(type, baseType); const implementedTypeNodes = getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { @@ -29437,11 +29444,6 @@ namespace ts { return getCheckFlags(s) & CheckFlags.Instantiated ? (s).target! : s; } - function getClassOrInterfaceDeclarationsOfSymbol(symbol: Symbol) { - return filter(symbol.declarations, (d: Declaration): d is ClassDeclaration | InterfaceDeclaration => - d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.InterfaceDeclaration); - } - /** * TypeScript 1.0 spec (April 2014): 8.2.3 * A derived class inherits all members from its base class it doesn't override. @@ -29529,11 +29531,6 @@ namespace ts { } continue; } - if (derivedDeclarationFlags & ModifiersFlags.Ambient) { - const errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_so_extended_class_2_must_provide_an_initializer_with_this_override; - error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); - continue; - } let errorMessage: DiagnosticMessage; if (isPrototypeProperty(base)) { @@ -29556,6 +29553,20 @@ namespace ts { } } + function checkAmbientPropertyMemberOverrides(type: Type, baseType?: Type) { + for (const derivedProperty of getPropertiesOfType(type)) { + const derived = getTargetSymbol(derivedProperty); + if (derived.flags & SymbolFlags.Prototype) { + continue; + } + const base = baseType && getPropertyOfObjectType(baseType, derived.escapedName); + if (!base && getDeclarationModifierFlagsFromSymbol(derived) & ModifierFlags.Ambient) { + const errorMessage = Diagnostics.Ambient_property_declarations_must_override_a_property_in_a_base_class; + error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage); + } + } + } + function checkInheritedPropertiesAreIdentical(type: InterfaceType, typeNode: Node): boolean { const baseTypes = getBaseTypes(type); if (baseTypes.length < 2) { @@ -29599,6 +29610,9 @@ namespace ts { } const constructor = findConstructorDeclaration(node); for (const member of node.members) { + if (getModifierFlags(member) & ModifierFlags.Ambient) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { const propName = (member).name; if (isIdentifier(propName)) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0200bf4b1b3d4..db471650a5cec 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2208,6 +2208,10 @@ "category": "Error", "code": 2610 }, + "Ambient property declarations must override a property in a base class.": { + "category": "Error", + "code": 2611 + }, "Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": { "category": "Error", "code": 2649 diff --git a/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt b/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt index f4b3fed7e5458..94f55b688b19b 100644 --- a/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt +++ b/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/classExpressionPropertyModifiers.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/compiler/classExpressionPropertyModifiers.ts(2,13): error TS2611: Ambient property declarations must override a property in a base class. +tests/cases/compiler/classExpressionPropertyModifiers.ts(2,36): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/classExpressionPropertyModifiers.ts(3,5): error TS1031: 'export' modifier cannot appear on a class element. -==== tests/cases/compiler/classExpressionPropertyModifiers.ts (2 errors) ==== +==== tests/cases/compiler/classExpressionPropertyModifiers.ts (3 errors) ==== const a = class Cat { declare [Symbol.toStringTag] = "uh"; - ~~~~~~~ -!!! error TS1031: 'declare' modifier cannot appear on a class element. + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2611: Ambient property declarations must override a property in a base class. + ~~~~ +!!! error TS1039: Initializers are not allowed in ambient contexts. export foo = 1; ~~~~~~ !!! error TS1031: 'export' modifier cannot appear on a class element. diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt index 7da5e3b68acce..2ab7155769834 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -1,28 +1,72 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(5,5): error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must provide an initializer with this override. -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(14,5): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(6,5): error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must provide an initializer with this override. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,5): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(16,13): error TS2611: Ambient property declarations must override a property in a base class. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(17,24): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(20,13): error TS2611: Ambient property declarations must override a property in a base class. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(24,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(39,5): error TS2610: Class 'E' defines instance member property 'p1', so extended class 'F' must provide an initializer with this override. -==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (2 errors) ==== +==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (9 errors) ==== class A { property = 'x'; + m() { return 1 } } class B extends A { - property; // error + property: any; // error ~~~~~~~~ !!! error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must provide an initializer with this override. } class BD extends A { - declare property; // still has implicit any + declare property: any; // ok because it's implicitly initialised } + class BDBang extends A { + declare property!: any; // doesn't need !, but is still allowed + } + class BOther extends A { + declare m() { return 2 } // not allowed on methods + ~~~~~~~ +!!! error TS1031: 'declare' modifier cannot appear on a class element. + declare nonce: any; // only allowed when exists in base + ~~~~~ +!!! error TS2611: Ambient property declarations must override a property in a base class. + declare property = 'y' // initialiser not allowed with declare + ~~~ +!!! error TS1039: Initializers are not allowed in ambient contexts. + } + class U { + declare nonce: any; // ambient declaration only allowed when an override + ~~~~~ +!!! error TS2611: Ambient property declarations must override a property in a base class. + } + class C { p: string; + ~ +!!! error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. } class D extends C { p: 'hi'; // error ~ +!!! error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. + ~ !!! error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. } class DD extends C { declare p: 'bye'; // ok } + + + declare class E { + p1: string + p2: string + } + class F extends E { + p1!: 'z' + ~~ +!!! error TS2610: Class 'E' defines instance member property 'p1', so extended class 'F' must provide an initializer with this override. + declare p2: 'alpha' + } \ No newline at end of file diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js index 748c143279e34..53e0dbb87f2cc 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js @@ -1,13 +1,26 @@ //// [derivedUninitializedPropertyDeclaration.ts] class A { property = 'x'; + m() { return 1 } } class B extends A { - property; // error + property: any; // error } class BD extends A { - declare property; // still has implicit any + declare property: any; // ok because it's implicitly initialised } +class BDBang extends A { + declare property!: any; // doesn't need !, but is still allowed +} +class BOther extends A { + declare m() { return 2 } // not allowed on methods + declare nonce: any; // only allowed when exists in base + declare property = 'y' // initialiser not allowed with declare +} +class U { + declare nonce: any; // ambient declaration only allowed when an override +} + class C { p: string; } @@ -17,9 +30,20 @@ class D extends C { class DD extends C { declare p: 'bye'; // ok } + + +declare class E { + p1: string + p2: string +} +class F extends E { + p1!: 'z' + declare p2: 'alpha' +} //// [derivedUninitializedPropertyDeclaration.js] +"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || @@ -37,6 +61,7 @@ var A = /** @class */ (function () { function A() { this.property = 'x'; } + A.prototype.m = function () { return 1; }; return A; }()); var B = /** @class */ (function (_super) { @@ -53,6 +78,28 @@ var BD = /** @class */ (function (_super) { } return BD; }(A)); +var BDBang = /** @class */ (function (_super) { + __extends(BDBang, _super); + function BDBang() { + return _super !== null && _super.apply(this, arguments) || this; + } + return BDBang; +}(A)); +var BOther = /** @class */ (function (_super) { + __extends(BOther, _super); + function BOther() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.property = 'y'; // initialiser not allowed with declare + return _this; + } + BOther.prototype.m = function () { return 2; }; // not allowed on methods + return BOther; +}(A)); +var U = /** @class */ (function () { + function U() { + } + return U; +}()); var C = /** @class */ (function () { function C() { } @@ -72,3 +119,10 @@ var DD = /** @class */ (function (_super) { } return DD; }(C)); +var F = /** @class */ (function (_super) { + __extends(F, _super); + function F() { + return _super !== null && _super.apply(this, arguments) || this; + } + return F; +}(E)); diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols index f18c1602880d6..78cc94074200b 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols @@ -4,39 +4,90 @@ class A { property = 'x'; >property : Symbol(A.property, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 9)) + + m() { return 1 } +>m : Symbol(A.m, Decl(derivedUninitializedPropertyDeclaration.ts, 1, 19)) } class B extends A { ->B : Symbol(B, Decl(derivedUninitializedPropertyDeclaration.ts, 2, 1)) +>B : Symbol(B, Decl(derivedUninitializedPropertyDeclaration.ts, 3, 1)) >A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) - property; // error ->property : Symbol(B.property, Decl(derivedUninitializedPropertyDeclaration.ts, 3, 19)) + property: any; // error +>property : Symbol(B.property, Decl(derivedUninitializedPropertyDeclaration.ts, 4, 19)) } class BD extends A { ->BD : Symbol(BD, Decl(derivedUninitializedPropertyDeclaration.ts, 5, 1)) +>BD : Symbol(BD, Decl(derivedUninitializedPropertyDeclaration.ts, 6, 1)) +>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) + + declare property: any; // ok because it's implicitly initialised +>property : Symbol(BD.property, Decl(derivedUninitializedPropertyDeclaration.ts, 7, 20)) +} +class BDBang extends A { +>BDBang : Symbol(BDBang, Decl(derivedUninitializedPropertyDeclaration.ts, 9, 1)) +>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) + + declare property!: any; // doesn't need !, but is still allowed +>property : Symbol(BDBang.property, Decl(derivedUninitializedPropertyDeclaration.ts, 10, 24)) +} +class BOther extends A { +>BOther : Symbol(BOther, Decl(derivedUninitializedPropertyDeclaration.ts, 12, 1)) >A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) - declare property; // still has implicit any ->property : Symbol(BD.property, Decl(derivedUninitializedPropertyDeclaration.ts, 6, 20)) + declare m() { return 2 } // not allowed on methods +>m : Symbol(BOther.m, Decl(derivedUninitializedPropertyDeclaration.ts, 13, 24)) + + declare nonce: any; // only allowed when exists in base +>nonce : Symbol(BOther.nonce, Decl(derivedUninitializedPropertyDeclaration.ts, 14, 28)) + + declare property = 'y' // initialiser not allowed with declare +>property : Symbol(BOther.property, Decl(derivedUninitializedPropertyDeclaration.ts, 15, 23)) +} +class U { +>U : Symbol(U, Decl(derivedUninitializedPropertyDeclaration.ts, 17, 1)) + + declare nonce: any; // ambient declaration only allowed when an override +>nonce : Symbol(U.nonce, Decl(derivedUninitializedPropertyDeclaration.ts, 18, 9)) } + class C { ->C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 8, 1)) +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 20, 1)) p: string; ->p : Symbol(C.p, Decl(derivedUninitializedPropertyDeclaration.ts, 9, 9)) +>p : Symbol(C.p, Decl(derivedUninitializedPropertyDeclaration.ts, 22, 9)) } class D extends C { ->D : Symbol(D, Decl(derivedUninitializedPropertyDeclaration.ts, 11, 1)) ->C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 8, 1)) +>D : Symbol(D, Decl(derivedUninitializedPropertyDeclaration.ts, 24, 1)) +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 20, 1)) p: 'hi'; // error ->p : Symbol(D.p, Decl(derivedUninitializedPropertyDeclaration.ts, 12, 19)) +>p : Symbol(D.p, Decl(derivedUninitializedPropertyDeclaration.ts, 25, 19)) } class DD extends C { ->DD : Symbol(DD, Decl(derivedUninitializedPropertyDeclaration.ts, 14, 1)) ->C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 8, 1)) +>DD : Symbol(DD, Decl(derivedUninitializedPropertyDeclaration.ts, 27, 1)) +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 20, 1)) declare p: 'bye'; // ok ->p : Symbol(DD.p, Decl(derivedUninitializedPropertyDeclaration.ts, 15, 20)) +>p : Symbol(DD.p, Decl(derivedUninitializedPropertyDeclaration.ts, 28, 20)) +} + + +declare class E { +>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1)) + + p1: string +>p1 : Symbol(E.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 33, 17)) + + p2: string +>p2 : Symbol(E.p2, Decl(derivedUninitializedPropertyDeclaration.ts, 34, 14)) +} +class F extends E { +>F : Symbol(F, Decl(derivedUninitializedPropertyDeclaration.ts, 36, 1)) +>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1)) + + p1!: 'z' +>p1 : Symbol(F.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 37, 19)) + + declare p2: 'alpha' +>p2 : Symbol(F.p2, Decl(derivedUninitializedPropertyDeclaration.ts, 38, 12)) } diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types index 693cc0dcd288e..0c284a704aec5 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types @@ -5,21 +5,54 @@ class A { property = 'x'; >property : string >'x' : "x" + + m() { return 1 } +>m : () => number +>1 : 1 } class B extends A { >B : B >A : A - property; // error + property: any; // error >property : any } class BD extends A { >BD : BD >A : A - declare property; // still has implicit any + declare property: any; // ok because it's implicitly initialised +>property : any +} +class BDBang extends A { +>BDBang : BDBang +>A : A + + declare property!: any; // doesn't need !, but is still allowed >property : any } +class BOther extends A { +>BOther : BOther +>A : A + + declare m() { return 2 } // not allowed on methods +>m : () => number +>2 : 2 + + declare nonce: any; // only allowed when exists in base +>nonce : any + + declare property = 'y' // initialiser not allowed with declare +>property : string +>'y' : "y" +} +class U { +>U : U + + declare nonce: any; // ambient declaration only allowed when an override +>nonce : any +} + class C { >C : C @@ -41,3 +74,24 @@ class DD extends C { >p : "bye" } + +declare class E { +>E : E + + p1: string +>p1 : string + + p2: string +>p2 : string +} +class F extends E { +>F : F +>E : E + + p1!: 'z' +>p1 : "z" + + declare p2: 'alpha' +>p2 : "alpha" +} + diff --git a/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt b/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt index eb373ad2fae07..d8e6e10158f54 100644 --- a/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt +++ b/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/illegalModifiersOnClassElements.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/compiler/illegalModifiersOnClassElements.ts(2,13): error TS2611: Ambient property declarations must override a property in a base class. +tests/cases/compiler/illegalModifiersOnClassElements.ts(2,19): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/illegalModifiersOnClassElements.ts(3,5): error TS1031: 'export' modifier cannot appear on a class element. -==== tests/cases/compiler/illegalModifiersOnClassElements.ts (2 errors) ==== +==== tests/cases/compiler/illegalModifiersOnClassElements.ts (3 errors) ==== class C { declare foo = 1; - ~~~~~~~ -!!! error TS1031: 'declare' modifier cannot appear on a class element. + ~~~ +!!! error TS2611: Ambient property declarations must override a property in a base class. + ~ +!!! error TS1039: Initializers are not allowed in ambient contexts. export bar = 1; ~~~~~~ !!! error TS1031: 'export' modifier cannot appear on a class element. diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration11.errors.txt b/tests/baselines/reference/parserMemberAccessorDeclaration11.errors.txt index 3a04bfbbd0296..47a9e27f73e2d 100644 --- a/tests/baselines/reference/parserMemberAccessorDeclaration11.errors.txt +++ b/tests/baselines/reference/parserMemberAccessorDeclaration11.errors.txt @@ -1,12 +1,15 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts(2,17): error TS2378: A 'get' accessor must return a value. +tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts(2,17): error TS2611: Ambient property declarations must override a property in a base class. -==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts (3 errors) ==== class C { declare get Foo() { } ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. ~~~ !!! error TS2378: A 'get' accessor must return a value. + ~~~ +!!! error TS2611: Ambient property declarations must override a property in a base class. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt index dc19cb0f8550a..25544ddeda5c4 100644 --- a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt +++ b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,13): error TS2611: Ambient property declarations must override a property in a base class. -==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (2 errors) ==== class C { declare Foo() { } ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. + ~~~ +!!! error TS2611: Ambient property declarations must override a property in a base class. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt b/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt index 2b2ea9664ceb4..9ad6081cdf6d9 100644 --- a/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt +++ b/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration5.ts(2,3): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration5.ts(2,11): error TS2611: Ambient property declarations must override a property in a base class. ==== tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration5.ts (1 errors) ==== class C { declare Foo; - ~~~~~~~ -!!! error TS1031: 'declare' modifier cannot appear on a class element. + ~~~ +!!! error TS2611: Ambient property declarations must override a property in a base class. } \ No newline at end of file diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts index 8988576b4f3e5..e57aa91ed6f35 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts @@ -4,19 +4,22 @@ class A { m() { return 1 } } class B extends A { - property; // error + property: any; // error } class BD extends A { - declare property; // still has implicit any, but is implicitly initialised + declare property: any; // ok because it's implicitly initialised } class BDBang extends A { - declare property!; // still has implicit any, doesn't need !, but has it anyway + declare property!: any; // doesn't need !, but is still allowed } class BOther extends A { declare m() { return 2 } // not allowed on methods - declare nonce; // only allowed when exists in base + declare nonce: any; // only allowed when exists in base declare property = 'y' // initialiser not allowed with declare } +class U { + declare nonce: any; // ambient declaration only allowed when an override +} class C { p: string; @@ -27,3 +30,13 @@ class D extends C { class DD extends C { declare p: 'bye'; // ok } + + +declare class E { + p1: string + p2: string +} +class F extends E { + p1!: 'z' + declare p2: 'alpha' +} From 868624293d156985e08eae49ab7a834b30c255ad Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 16 Sep 2019 15:06:53 -0700 Subject: [PATCH 04/17] Check for constructor initialisation --- src/compiler/checker.ts | 21 ++++++++---- ...ninitializedPropertyDeclaration.errors.txt | 13 ++++++++ ...derivedUninitializedPropertyDeclaration.js | 29 +++++++++++++++++ ...edUninitializedPropertyDeclaration.symbols | 29 +++++++++++++++++ ...ivedUninitializedPropertyDeclaration.types | 32 +++++++++++++++++++ ...derivedUninitializedPropertyDeclaration.ts | 13 ++++++++ ...erivedTypeIndexerWithGenericConstraints.ts | 2 +- 7 files changed, 132 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bf614c2068568..5c2c382c82759 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29520,14 +29520,23 @@ namespace ts { continue; } if (base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) { - if (derived.flags & SymbolFlags.Property + const uninitialized = find(derived.declarations, d => d.kind === SyntaxKind.PropertyDeclaration && !(d as PropertyDeclaration).initializer); + if (uninitialized + && derived.flags & SymbolFlags.Property && !(derived.flags & SymbolFlags.Transient) && !(baseDeclarationFlags & ModifierFlags.Abstract) - && !(derivedDeclarationFlags & ModifierFlags.Ambient) - && !derived.declarations.some(d => d.flags & NodeFlags.Ambient) - && derived.declarations.some(d => d.kind === SyntaxKind.PropertyDeclaration && !(d as PropertyDeclaration).initializer)) { - const errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_so_extended_class_2_must_provide_an_initializer_with_this_override; - error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + && !(derivedDeclarationFlags & (ModifierFlags.Ambient | ModifierFlags.Abstract)) + && !derived.declarations.some(d => d.flags & NodeFlags.Ambient)) { + const constructor = findConstructorDeclaration(getClassLikeDeclarationOfSymbol(type.symbol)!); + const propName = (uninitialized as PropertyDeclaration).name; + if ((uninitialized as PropertyDeclaration).exclamationToken + || !constructor + || !isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + const errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_so_extended_class_2_must_provide_an_initializer_with_this_override; + error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + } } continue; } diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt index 2ab7155769834..bcdc550758420 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -69,4 +69,17 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP !!! error TS2610: Class 'E' defines instance member property 'p1', so extended class 'F' must provide an initializer with this override. declare p2: 'alpha' } + + class G extends E { + p1: 'z' + constructor() { + super() + this.p1 = 'z' + } + } + + abstract class H extends E { + abstract p1: 'a' | 'b' | 'c' + declare abstract p2: 'a' | 'b' | 'c' + } \ No newline at end of file diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js index 53e0dbb87f2cc..a07c27531cfd5 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js @@ -40,6 +40,19 @@ class F extends E { p1!: 'z' declare p2: 'alpha' } + +class G extends E { + p1: 'z' + constructor() { + super() + this.p1 = 'z' + } +} + +abstract class H extends E { + abstract p1: 'a' | 'b' | 'c' + declare abstract p2: 'a' | 'b' | 'c' +} //// [derivedUninitializedPropertyDeclaration.js] @@ -126,3 +139,19 @@ var F = /** @class */ (function (_super) { } return F; }(E)); +var G = /** @class */ (function (_super) { + __extends(G, _super); + function G() { + var _this = _super.call(this) || this; + _this.p1 = 'z'; + return _this; + } + return G; +}(E)); +var H = /** @class */ (function (_super) { + __extends(H, _super); + function H() { + return _super !== null && _super.apply(this, arguments) || this; + } + return H; +}(E)); diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols index 78cc94074200b..298022d3c2fd1 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols @@ -91,3 +91,32 @@ class F extends E { >p2 : Symbol(F.p2, Decl(derivedUninitializedPropertyDeclaration.ts, 38, 12)) } +class G extends E { +>G : Symbol(G, Decl(derivedUninitializedPropertyDeclaration.ts, 40, 1)) +>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1)) + + p1: 'z' +>p1 : Symbol(G.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 42, 19)) + + constructor() { + super() +>super : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1)) + + this.p1 = 'z' +>this.p1 : Symbol(G.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 42, 19)) +>this : Symbol(G, Decl(derivedUninitializedPropertyDeclaration.ts, 40, 1)) +>p1 : Symbol(G.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 42, 19)) + } +} + +abstract class H extends E { +>H : Symbol(H, Decl(derivedUninitializedPropertyDeclaration.ts, 48, 1)) +>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1)) + + abstract p1: 'a' | 'b' | 'c' +>p1 : Symbol(H.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 50, 28)) + + declare abstract p2: 'a' | 'b' | 'c' +>p2 : Symbol(H.p2, Decl(derivedUninitializedPropertyDeclaration.ts, 51, 32)) +} + diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types index 0c284a704aec5..44d839492b5eb 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types @@ -95,3 +95,35 @@ class F extends E { >p2 : "alpha" } +class G extends E { +>G : G +>E : E + + p1: 'z' +>p1 : "z" + + constructor() { + super() +>super() : void +>super : typeof E + + this.p1 = 'z' +>this.p1 = 'z' : "z" +>this.p1 : "z" +>this : this +>p1 : "z" +>'z' : "z" + } +} + +abstract class H extends E { +>H : H +>E : E + + abstract p1: 'a' | 'b' | 'c' +>p1 : "a" | "b" | "c" + + declare abstract p2: 'a' | 'b' | 'c' +>p2 : "a" | "b" | "c" +} + diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts index e57aa91ed6f35..fa4fd86f01e85 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts @@ -40,3 +40,16 @@ class F extends E { p1!: 'z' declare p2: 'alpha' } + +class G extends E { + p1: 'z' + constructor() { + super() + this.p1 = 'z' + } +} + +abstract class H extends E { + abstract p1: 'a' | 'b' | 'c' + declare abstract p2: 'a' | 'b' | 'c' +} diff --git a/tests/cases/fourslash/derivedTypeIndexerWithGenericConstraints.ts b/tests/cases/fourslash/derivedTypeIndexerWithGenericConstraints.ts index 21489b5d8aa9b..82dfe9429e1b2 100644 --- a/tests/cases/fourslash/derivedTypeIndexerWithGenericConstraints.ts +++ b/tests/cases/fourslash/derivedTypeIndexerWithGenericConstraints.ts @@ -13,7 +13,7 @@ ////} ////class DbSet extends BaseCollection { // error -//// _itemsByKey: { [key: string]: TEntity; }; +//// _itemsByKey: { [key: string]: TEntity; } = {}; ////} ////var a: BaseCollection; From 2916c29204de34bb7dbbef93a18b18d9c4dd8ec4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 16 Sep 2019 15:48:27 -0700 Subject: [PATCH 05/17] change error wording --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- .../apparentTypeSubtyping.errors.txt | 8 +- .../apparentTypeSupertype.errors.txt | 4 +- ...baseClassImprovedMismatchErrors.errors.txt | 4 +- .../classIsSubtypeOfBaseType.errors.txt | 8 +- ...declarationEmitProtectedMembers.errors.txt | 4 +- ...dClassOverridesProtectedMembers.errors.txt | 8 +- ...ClassOverridesProtectedMembers2.errors.txt | 8 +- ...ClassOverridesProtectedMembers3.errors.txt | 8 +- ...ClassOverridesProtectedMembers4.errors.txt | 8 +- ...ivedClassOverridesPublicMembers.errors.txt | 8 +- ...vedClassOverridesWithoutSubtype.errors.txt | 4 +- .../reference/derivedClassWithAny.errors.txt | 8 +- .../derivedGenericClassWithAny.errors.txt | 8 +- ...ninitializedPropertyDeclaration.errors.txt | 12 +-- .../genericPrototypeProperty2.errors.txt | 8 +- .../genericPrototypeProperty3.errors.txt | 8 +- ...aceExtendingClassWithProtecteds.errors.txt | 4 +- .../reference/inheritance.errors.txt | 4 +- ...emberPropertyOverridingAccessor.errors.txt | 4 +- ...emberPropertyOverridingProperty.errors.txt | 4 +- .../instanceSubtypeCheck2.errors.txt | 4 +- ...erfaceExtendsObjectIntersection.errors.txt | 28 +++--- ...ExtendsObjectIntersectionErrors.errors.txt | 20 ++--- .../reference/multipleInheritance.errors.txt | 4 +- .../mutuallyRecursiveInference.errors.txt | 8 +- .../reference/protectedMembers.errors.txt | 12 +-- .../baselines/reference/scopeTests.errors.txt | 4 +- .../subtypesOfTypeParameter.errors.txt | 4 +- ...OfTypeParameterWithConstraints4.errors.txt | 36 ++++---- ...rameterWithRecursiveConstraints.errors.txt | 72 +++++++-------- .../subtypingTransitivity.errors.txt | 8 +- .../subtypingWithObjectMembers.errors.txt | 48 +++++----- .../tsxGenericAttributesType5.errors.txt | 4 +- .../tsxGenericAttributesType6.errors.txt | 4 +- .../undefinedIsSubtypeOfEverything.errors.txt | 88 +++++++++---------- 37 files changed, 240 insertions(+), 240 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5c2c382c82759..1a26abaaa4abf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29534,7 +29534,7 @@ namespace ts { || !isIdentifier(propName) || !strictNullChecks || !isPropertyInitializedInConstructor(propName, type, constructor)) { - const errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_so_extended_class_2_must_provide_an_initializer_with_this_override; + const errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_so_extended_class_2_must_use_declare_to_make_it_ambient; error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index db471650a5cec..b0f8ca8e24ed2 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2204,7 +2204,7 @@ "category": "Error", "code": 2609 }, - "Class '{0}' defines instance member property '{1}', so extended class '{2}' must provide an initializer with this override.": { + "Class '{0}' defines instance member property '{1}', so extended class '{2}' must use 'declare' to make it ambient.": { "category": "Error", "code": 2610 }, diff --git a/tests/baselines/reference/apparentTypeSubtyping.errors.txt b/tests/baselines/reference/apparentTypeSubtyping.errors.txt index 92ce3a37c3c35..e4088efe246a7 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.errors.txt +++ b/tests/baselines/reference/apparentTypeSubtyping.errors.txt @@ -1,8 +1,8 @@ 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 'Base'. 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 TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(20,5): error TS2610: Class 'Base2' defines instance member property 'x', so extended class 'Derived2' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(10,5): error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(20,5): error TS2610: Class 'Base2' defines instance member property 'x', so extended class 'Derived2' must use 'declare' to make it ambient. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts (3 errors) ==== @@ -21,7 +21,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi !!! 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. ~ -!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. } class Base2 { @@ -33,5 +33,5 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi class Derived2 extends Base2 { // error because of the prototype's not matching, not because of the instance side x: U; ~ -!!! error TS2610: Class 'Base2' defines instance member property 'x', so extended class 'Derived2' must provide an initializer with this override. +!!! error TS2610: Class 'Base2' defines instance member property 'x', so extended class 'Derived2' must use 'declare' to make it ambient. } \ No newline at end of file diff --git a/tests/baselines/reference/apparentTypeSupertype.errors.txt b/tests/baselines/reference/apparentTypeSupertype.errors.txt index 23e4ee3cb3512..5d13848277882 100644 --- a/tests/baselines/reference/apparentTypeSupertype.errors.txt +++ b/tests/baselines/reference/apparentTypeSupertype.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty 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 TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts(10,5): error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (2 errors) ==== @@ -22,5 +22,5 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty !!! 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. ~ -!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. } \ No newline at end of file diff --git a/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt b/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt index 9a097955fde14..b654bfa37d072 100644 --- a/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt +++ b/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2416: Prop 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'. -tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2610: Class 'Base' defines instance member property 'n', so extended class 'Derived' must provide an initializer with this override. +tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2610: Class 'Base' defines instance member property 'n', so extended class 'Derived' must use 'declare' to make it ambient. tests/cases/compiler/baseClassImprovedMismatchErrors.ts(9,5): error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type 'Base'. Type '() => string | number' is not assignable to type '() => number'. Type 'string | number' is not assignable to type 'number'. @@ -41,7 +41,7 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(15,5): error TS2416: Pro !!! error TS2416: Type 'string | Derived' is not assignable to type 'string | Base'. !!! error TS2416: Type 'Derived' is not assignable to type 'string | Base'. ~ -!!! error TS2610: Class 'Base' defines instance member property 'n', so extended class 'Derived' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'n', so extended class 'Derived' must use 'declare' to make it ambient. fn() { ~~ !!! error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type 'Base'. diff --git a/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt b/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt index f59f03763efa0..86370198f2c6e 100644 --- a/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt +++ b/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(6,5): error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived' must provide an initializer with this override. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(6,5): error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived' must use 'declare' to make it ambient. 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 'Base<{ 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(12,5): error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived2' must provide an initializer with this override. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(12,5): error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived2' must use 'declare' to make it ambient. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts (3 errors) ==== @@ -13,7 +13,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla class Derived extends Base<{ bar: string; }> { foo: { ~~~ -!!! error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived' must provide an initializer with this override. +!!! error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived' must use 'declare' to make it ambient. bar: string; baz: number; // ok } } @@ -25,7 +25,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla !!! 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; }'. ~~~ -!!! error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived2' must provide an initializer with this override. +!!! error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived2' must use 'declare' to make it ambient. bar?: string; // error } } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt b/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt index ee19970f04d14..803f761654333 100644 --- a/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt +++ b/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/declarationEmitProtectedMembers.ts(34,5): error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. +tests/cases/compiler/declarationEmitProtectedMembers.ts(34,5): error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. ==== tests/cases/compiler/declarationEmitProtectedMembers.ts (1 errors) ==== @@ -37,7 +37,7 @@ tests/cases/compiler/declarationEmitProtectedMembers.ts(34,5): error TS2610: Cla class C3 extends C2 { x: number; ~ -!!! error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. +!!! error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. static sx: number; f() { return super.f(); diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt index 645abc21fc0f1..cbf6d7f53c228 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(21,15): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(25,15): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(21,15): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(25,15): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. ==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts (2 errors) ==== @@ -25,13 +25,13 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived extends Base { protected a: typeof y; ~ -!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. protected b(a: typeof y) { } protected get c() { return y; } protected set c(v: typeof y) { } protected d: (a: typeof y) => void; ~ -!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. protected static r: typeof y; protected static s(a: typeof y) { } diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt index 51677922dccda..b739769498fbf 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(22,5): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(26,5): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(22,5): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(26,5): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. ==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts (2 errors) ==== @@ -26,13 +26,13 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived extends Base { a: typeof y; ~ -!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. b(a: typeof y) { } get c() { return y; } set c(v: typeof y) { } d: (a: typeof y) => void; ~ -!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. static r: typeof y; static s(a: typeof y) { } diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt index 6fdb020e366c4..4c74d97f040a9 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(22,7): error TS2415: Class 'Derived1' incorrectly extends base class 'Base'. Property 'a' is protected in type 'Derived1' but public in type 'Base'. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(23,15): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(23,15): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must use 'declare' to make it ambient. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(27,7): error TS2415: Class 'Derived2' incorrectly extends base class 'Base'. Property 'b' is protected in type 'Derived2' but public in type 'Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(32,7): error TS2415: Class 'Derived3' incorrectly extends base class 'Base'. @@ -9,7 +9,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve Property 'c' is protected in type 'Derived4' but public in type 'Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(42,7): error TS2415: Class 'Derived5' incorrectly extends base class 'Base'. Property 'd' is protected in type 'Derived5' but public in type 'Base'. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(43,15): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived5' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(43,15): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived5' must use 'declare' to make it ambient. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(47,7): error TS2417: Class static side 'typeof Derived6' incorrectly extends base class static side 'typeof Base'. Property 'r' is protected in type 'typeof Derived6' but public in type 'typeof Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(52,7): error TS2417: Class static side 'typeof Derived7' incorrectly extends base class static side 'typeof Base'. @@ -50,7 +50,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve !!! error TS2415: Property 'a' is protected in type 'Derived1' but public in type 'Base'. protected a: typeof x; ~ -!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must use 'declare' to make it ambient. constructor(a: typeof x) { super(a); } } @@ -84,7 +84,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve !!! error TS2415: Property 'd' is protected in type 'Derived5' but public in type 'Base'. protected d: (a: typeof x) => void ; ~ -!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived5' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived5' must use 'declare' to make it ambient. constructor(a: typeof x) { super(a); } } diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt index 00eecd17d899a..9f401ea1e5668 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(9,12): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(9,12): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must use 'declare' to make it ambient. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(12,7): error TS2415: Class 'Derived2' incorrectly extends base class 'Derived1'. Property 'a' is protected in type 'Derived2' but public in type 'Derived1'. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(13,15): error TS2610: Class 'Derived1' defines instance member property 'a', so extended class 'Derived2' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(13,15): error TS2610: Class 'Derived1' defines instance member property 'a', so extended class 'Derived2' must use 'declare' to make it ambient. ==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts (3 errors) ==== @@ -15,7 +15,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived1 extends Base { public a: typeof x; ~ -!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must use 'declare' to make it ambient. } class Derived2 extends Derived1 { @@ -24,5 +24,5 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve !!! error TS2415: Property 'a' is protected in type 'Derived2' but public in type 'Derived1'. protected a: typeof x; // Error, parent was public ~ -!!! error TS2610: Class 'Derived1' defines instance member property 'a', so extended class 'Derived2' must provide an initializer with this override. +!!! error TS2610: Class 'Derived1' defines instance member property 'a', so extended class 'Derived2' must use 'declare' to make it ambient. } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt b/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt index 19273eebe347d..145350ee604f9 100644 --- a/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt @@ -2,10 +2,10 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(13,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(14,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(21,5): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(21,5): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(24,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(25,5): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(25,5): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(29,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(30,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -41,7 +41,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived extends Base { a: typeof y; ~ -!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. b(a: typeof y) { } get c() { return y; } ~ @@ -51,7 +51,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. d: (a: typeof y) => void; ~ -!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. static r: typeof y; static s(a: typeof y) { } diff --git a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt index 46e01f242e299..7a7633d461c6e 100644 --- a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesWithoutSubtype.ts(8,5): error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesWithoutSubtype.ts(8,5): error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. ==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesWithoutSubtype.ts (1 errors) ==== @@ -11,7 +11,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived extends Base { x: { ~ -!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. foo: any; } } diff --git a/tests/baselines/reference/derivedClassWithAny.errors.txt b/tests/baselines/reference/derivedClassWithAny.errors.txt index 37cb69218f432..c2037c529cfb0 100644 --- a/tests/baselines/reference/derivedClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedClassWithAny.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(18,5): error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(18,5): error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(19,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(27,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(37,5): error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(37,5): error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must use 'declare' to make it ambient. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(38,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(44,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(57,1): error TS2322: Type 'E' is not assignable to type 'C'. @@ -35,7 +35,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit class D extends C { x: any; ~ -!!! error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. +!!! error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. get X(): any { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -60,7 +60,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit class E extends D { x: string; ~ -!!! error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must provide an initializer with this override. +!!! error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must use 'declare' to make it ambient. get X(): string{ return ''; } ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt index d7d4167c342e3..d5dc9585271d2 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(10,5): error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(10,5): error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(19,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(29,5): error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must provide an initializer with this override. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(29,5): error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must use 'declare' to make it ambient. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,18): error TS2322: Type '""' is not assignable to type 'T'. '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. @@ -27,7 +27,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC class D extends C { x: any; ~ -!!! error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. +!!! error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. get X(): any { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -52,7 +52,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC class E extends D { x: T; ~ -!!! error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must provide an initializer with this override. +!!! error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must use 'declare' to make it ambient. get X(): T { return ''; } // error ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt index bcdc550758420..aa9f4b955938d 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(6,5): error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must provide an initializer with this override. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(6,5): error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must use 'declare' to make it ambient. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,5): error TS1031: 'declare' modifier cannot appear on a class element. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(16,13): error TS2611: Ambient property declarations must override a property in a base class. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(17,24): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(20,13): error TS2611: Ambient property declarations must override a property in a base class. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(24,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(39,5): error TS2610: Class 'E' defines instance member property 'p1', so extended class 'F' must provide an initializer with this override. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must use 'declare' to make it ambient. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(39,5): error TS2610: Class 'E' defines instance member property 'p1', so extended class 'F' must use 'declare' to make it ambient. ==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (9 errors) ==== @@ -17,7 +17,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP class B extends A { property: any; // error ~~~~~~~~ -!!! error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must provide an initializer with this override. +!!! error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must use 'declare' to make it ambient. } class BD extends A { declare property: any; // ok because it's implicitly initialised @@ -52,7 +52,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP ~ !!! error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. ~ -!!! error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. +!!! error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must use 'declare' to make it ambient. } class DD extends C { declare p: 'bye'; // ok @@ -66,7 +66,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP class F extends E { p1!: 'z' ~~ -!!! error TS2610: Class 'E' defines instance member property 'p1', so extended class 'F' must provide an initializer with this override. +!!! error TS2610: Class 'E' defines instance member property 'p1', so extended class 'F' must use 'declare' to make it ambient. declare p2: 'alpha' } diff --git a/tests/baselines/reference/genericPrototypeProperty2.errors.txt b/tests/baselines/reference/genericPrototypeProperty2.errors.txt index 212abb8d79552..117cc90b99fae 100644 --- a/tests/baselines/reference/genericPrototypeProperty2.errors.txt +++ b/tests/baselines/reference/genericPrototypeProperty2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/genericPrototypeProperty2.ts(7,5): error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must provide an initializer with this override. -tests/cases/compiler/genericPrototypeProperty2.ts(14,5): error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must provide an initializer with this override. +tests/cases/compiler/genericPrototypeProperty2.ts(7,5): error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must use 'declare' to make it ambient. +tests/cases/compiler/genericPrototypeProperty2.ts(14,5): error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must use 'declare' to make it ambient. ==== tests/cases/compiler/genericPrototypeProperty2.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/genericPrototypeProperty2.ts(14,5): error TS2610: Class 'Ba class MyEvent extends BaseEvent { target: T; ~~~~~~ -!!! error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must provide an initializer with this override. +!!! error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must use 'declare' to make it ambient. } class BaseEventWrapper { t: BaseEvent; @@ -20,5 +20,5 @@ tests/cases/compiler/genericPrototypeProperty2.ts(14,5): error TS2610: Class 'Ba class MyEventWrapper extends BaseEventWrapper { t: MyEvent; // any satisfies constraint and passes assignability check between 'target' properties ~ -!!! error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must provide an initializer with this override. +!!! error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must use 'declare' to make it ambient. } \ No newline at end of file diff --git a/tests/baselines/reference/genericPrototypeProperty3.errors.txt b/tests/baselines/reference/genericPrototypeProperty3.errors.txt index d13518f48135e..ca3398d6722d3 100644 --- a/tests/baselines/reference/genericPrototypeProperty3.errors.txt +++ b/tests/baselines/reference/genericPrototypeProperty3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/genericPrototypeProperty3.ts(6,5): error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must provide an initializer with this override. -tests/cases/compiler/genericPrototypeProperty3.ts(13,5): error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must provide an initializer with this override. +tests/cases/compiler/genericPrototypeProperty3.ts(6,5): error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must use 'declare' to make it ambient. +tests/cases/compiler/genericPrototypeProperty3.ts(13,5): error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must use 'declare' to make it ambient. ==== tests/cases/compiler/genericPrototypeProperty3.ts (2 errors) ==== @@ -10,7 +10,7 @@ tests/cases/compiler/genericPrototypeProperty3.ts(13,5): error TS2610: Class 'Ba class MyEvent extends BaseEvent { // T is instantiated to any in the prototype, which is assignable to {} target: T; ~~~~~~ -!!! error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must provide an initializer with this override. +!!! error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must use 'declare' to make it ambient. } class BaseEventWrapper { t: BaseEvent; @@ -19,5 +19,5 @@ tests/cases/compiler/genericPrototypeProperty3.ts(13,5): error TS2610: Class 'Ba class MyEventWrapper extends BaseEventWrapper { t: MyEvent; ~ -!!! error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must provide an initializer with this override. +!!! error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must use 'declare' to make it ambient. } \ No newline at end of file diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt index b4ca2536ac5bd..98aee8dd231f7 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt @@ -10,7 +10,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte Property 'y' is missing in type 'Bar5' but required in type 'I'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(29,7): error TS2420: Class 'Bar6' incorrectly implements interface 'I'. Property 'y' is protected in type 'Bar6' but public in type 'I'. -tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(38,5): error TS2610: Class 'Foo' defines instance member property 'x', so extended class 'Bar8' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(38,5): error TS2610: Class 'Foo' defines instance member property 'x', so extended class 'Bar8' must use 'declare' to make it ambient. ==== tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts (7 errors) ==== @@ -73,7 +73,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte class Bar8 extends Foo implements I { x: string; ~ -!!! error TS2610: Class 'Foo' defines instance member property 'x', so extended class 'Bar8' must provide an initializer with this override. +!!! error TS2610: Class 'Foo' defines instance member property 'x', so extended class 'Bar8' must use 'declare' to make it ambient. y: number; } \ No newline at end of file diff --git a/tests/baselines/reference/inheritance.errors.txt b/tests/baselines/reference/inheritance.errors.txt index 12994b1c87665..9b589f51a0b0e 100644 --- a/tests/baselines/reference/inheritance.errors.txt +++ b/tests/baselines/reference/inheritance.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/inheritance.ts(22,12): error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must provide an initializer with this override. +tests/cases/compiler/inheritance.ts(22,12): error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must use 'declare' to make it ambient. 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 'Good'. Type '(n: number) => number' is not assignable to type '() => number'. @@ -28,7 +28,7 @@ tests/cases/compiler/inheritance.ts(32,12): error TS2416: Property 'g' in type ' class ND extends N { // any is assignable to number public y; ~ -!!! error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must provide an initializer with this override. +!!! error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must use 'declare' to make it ambient. } class Good { diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt index 9491f47ff133b..18f70505450b4 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(6,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(12,5): error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must provide an initializer with this override. +tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(12,5): error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must use 'declare' to make it ambient. ==== tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts (3 errors) ==== @@ -21,5 +21,5 @@ tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(12,5): error class b extends a { x: () => string; ~ -!!! error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must provide an initializer with this override. +!!! error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must use 'declare' to make it ambient. } \ No newline at end of file diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt index ed604c5260725..ee3da3f95a37d 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts(6,5): error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must provide an initializer with this override. +tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts(6,5): error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must use 'declare' to make it ambient. ==== tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts (1 errors) ==== @@ -9,5 +9,5 @@ tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts(6,5): error class b extends a { x: () => string; ~ -!!! error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must provide an initializer with this override. +!!! error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must use 'declare' to make it ambient. } \ No newline at end of file diff --git a/tests/baselines/reference/instanceSubtypeCheck2.errors.txt b/tests/baselines/reference/instanceSubtypeCheck2.errors.txt index cd53a1304c246..4640ae46fc29f 100644 --- a/tests/baselines/reference/instanceSubtypeCheck2.errors.txt +++ b/tests/baselines/reference/instanceSubtypeCheck2.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2416: Property 'x' in type 'C2' is not assignable to the same property in base type 'C1'. Type 'string' is not assignable to type 'C2'. -tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2610: Class 'C1' defines instance member property 'x', so extended class 'C2' must provide an initializer with this override. +tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2610: Class 'C1' defines instance member property 'x', so extended class 'C2' must use 'declare' to make it ambient. ==== tests/cases/compiler/instanceSubtypeCheck2.ts (2 errors) ==== @@ -14,5 +14,5 @@ tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2610: Class 'C1' !!! error TS2416: Property 'x' in type 'C2' is not assignable to the same property in base type 'C1'. !!! error TS2416: Type 'string' is not assignable to type 'C2'. ~ -!!! error TS2610: Class 'C1' defines instance member property 'x', so extended class 'C2' must provide an initializer with this override. +!!! error TS2610: Class 'C1' defines instance member property 'x', so extended class 'C2' must use 'declare' to make it ambient. } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt index a200f3bffe1e4..4778cd7e0f2f2 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt +++ b/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(20,38): error TS2610: Class 'I1' defines instance member property 'x', so extended class 'C1' must provide an initializer with this override. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(21,38): error TS2610: Class 'I2' defines instance member property 'x', so extended class 'C2' must provide an initializer with this override. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(22,38): error TS2610: Class 'I3' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(23,38): error TS2610: Class 'I4' defines instance member property 'x', so extended class 'C4' must provide an initializer with this override. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(24,38): error TS2610: Class 'I5' defines instance member property 'x', so extended class 'C5' must provide an initializer with this override. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(25,38): error TS2610: Class 'I6' defines instance member property 'x', so extended class 'C6' must provide an initializer with this override. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(26,38): error TS2610: Class 'I7' defines instance member property 'x', so extended class 'C7' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(20,38): error TS2610: Class 'I1' defines instance member property 'x', so extended class 'C1' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(21,38): error TS2610: Class 'I2' defines instance member property 'x', so extended class 'C2' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(22,38): error TS2610: Class 'I3' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(23,38): error TS2610: Class 'I4' defines instance member property 'x', so extended class 'C4' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(24,38): error TS2610: Class 'I5' defines instance member property 'x', so extended class 'C5' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(25,38): error TS2610: Class 'I6' defines instance member property 'x', so extended class 'C6' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(26,38): error TS2610: Class 'I7' defines instance member property 'x', so extended class 'C7' must use 'declare' to make it ambient. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts (7 errors) ==== @@ -29,25 +29,25 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI class C1 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I1' defines instance member property 'x', so extended class 'C1' must provide an initializer with this override. +!!! error TS2610: Class 'I1' defines instance member property 'x', so extended class 'C1' must use 'declare' to make it ambient. class C2 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I2' defines instance member property 'x', so extended class 'C2' must provide an initializer with this override. +!!! error TS2610: Class 'I2' defines instance member property 'x', so extended class 'C2' must use 'declare' to make it ambient. class C3 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I3' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. +!!! error TS2610: Class 'I3' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. class C4 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I4' defines instance member property 'x', so extended class 'C4' must provide an initializer with this override. +!!! error TS2610: Class 'I4' defines instance member property 'x', so extended class 'C4' must use 'declare' to make it ambient. class C5 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I5' defines instance member property 'x', so extended class 'C5' must provide an initializer with this override. +!!! error TS2610: Class 'I5' defines instance member property 'x', so extended class 'C5' must use 'declare' to make it ambient. class C6 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I6' defines instance member property 'x', so extended class 'C6' must provide an initializer with this override. +!!! error TS2610: Class 'I6' defines instance member property 'x', so extended class 'C6' must use 'declare' to make it ambient. class C7 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I7' defines instance member property 'x', so extended class 'C7' must provide an initializer with this override. +!!! error TS2610: Class 'I7' defines instance member property 'x', so extended class 'C7' must use 'declare' to make it ambient. declare function fx(x: string): string; declare class CX { a: number } diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt index 9acd77695b67d..0f4a62fd786ac 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt @@ -16,19 +16,19 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI 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 'T1'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(16,38): error TS2610: Class 'T1' defines instance member property 'a', so extended class 'C1' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(16,38): error TS2610: Class 'T1' defines instance member property 'a', so extended class 'C1' must use 'declare' to make it ambient. 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 'T2'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,38): error TS2610: Class 'T2' defines instance member property 'b', so extended class 'C2' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,38): error TS2610: Class 'T2' defines instance member property 'b', so extended class 'C2' must use 'declare' to make it ambient. 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(18,38): error TS2610: Class 'number[]' defines instance member property 'length', so extended class 'C3' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(18,38): error TS2610: Class 'number[]' defines instance member property 'length', so extended class 'C3' must use 'declare' to make it ambient. 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, number]'. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,38): error TS2610: Class '[string, number]' defines instance member property '0', so extended class 'C4' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,38): error TS2610: Class '[string, number]' defines instance member property '0', so extended class 'C4' must use 'declare' to make it ambient. 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 'T5'. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(20,38): error TS2610: Class 'T5' defines instance member property 'c', so extended class 'C5' must provide an initializer with this override. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(20,38): error TS2610: Class 'T5' defines instance member property 'c', so extended class 'C5' must use 'declare' to make it ambient. 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'. @@ -102,31 +102,31 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI !!! error TS2416: Property 'a' in type 'C1' is not assignable to the same property in base type 'T1'. !!! error TS2416: Type 'string' is not assignable to type 'number'. ~ -!!! error TS2610: Class 'T1' defines instance member property 'a', so extended class 'C1' must provide an initializer with this override. +!!! error TS2610: Class 'T1' defines instance member property 'a', so extended class 'C1' must use 'declare' to make it ambient. class C2 extends Constructor() { b: string } ~ !!! error TS2416: Property 'b' in type 'C2' is not assignable to the same property in base type 'T2'. !!! error TS2416: Type 'string' is not assignable to type 'number'. ~ -!!! error TS2610: Class 'T2' defines instance member property 'b', so extended class 'C2' must provide an initializer with this override. +!!! error TS2610: Class 'T2' defines instance member property 'b', so extended class 'C2' must use 'declare' to make it ambient. class C3 extends Constructor() { length: string } ~~~~~~ !!! 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'. ~~~~~~ -!!! error TS2610: Class 'number[]' defines instance member property 'length', so extended class 'C3' must provide an initializer with this override. +!!! error TS2610: Class 'number[]' defines instance member property 'length', so extended class 'C3' must use 'declare' to make it ambient. class C4 extends Constructor() { 0: number } ~ !!! error TS2416: Property '0' in type 'C4' is not assignable to the same property in base type '[string, number]'. !!! error TS2416: Type 'number' is not assignable to type 'string'. ~ -!!! error TS2610: Class '[string, number]' defines instance member property '0', so extended class 'C4' must provide an initializer with this override. +!!! error TS2610: Class '[string, number]' defines instance member property '0', so extended class 'C4' must use 'declare' to make it ambient. class C5 extends Constructor() { c: number } ~ !!! error TS2416: Property 'c' in type 'C5' is not assignable to the same property in base type 'T5'. !!! error TS2416: Type 'number' is not assignable to type 'string'. ~ -!!! error TS2610: Class 'T5' defines instance member property 'c', so extended class 'C5' must provide an initializer with this override. +!!! error TS2610: Class 'T5' defines instance member property 'c', so extended class 'C5' must use 'declare' to make it ambient. declare class CX { static a: string } declare enum EX { A, B, C } diff --git a/tests/baselines/reference/multipleInheritance.errors.txt b/tests/baselines/reference/multipleInheritance.errors.txt index b3e6a02c72942..0f4e79738e9e6 100644 --- a/tests/baselines/reference/multipleInheritance.errors.txt +++ b/tests/baselines/reference/multipleInheritance.errors.txt @@ -1,6 +1,6 @@ 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(26,12): error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must provide an initializer with this override. +tests/cases/compiler/multipleInheritance.ts(26,12): error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must use 'declare' to make it ambient. 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 'Good'. Type '(n: number) => number' is not assignable to type '() => number'. @@ -38,7 +38,7 @@ tests/cases/compiler/multipleInheritance.ts(36,12): error TS2416: Property 'g' i class ND extends N { // any is assignable to number public y; ~ -!!! error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must provide an initializer with this override. +!!! error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must use 'declare' to make it ambient. } class Good { diff --git a/tests/baselines/reference/mutuallyRecursiveInference.errors.txt b/tests/baselines/reference/mutuallyRecursiveInference.errors.txt index 9f5b1852c7c47..f6b5d58430f4b 100644 --- a/tests/baselines/reference/mutuallyRecursiveInference.errors.txt +++ b/tests/baselines/reference/mutuallyRecursiveInference.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/mutuallyRecursiveInference.ts(9,5): error TS2610: Class 'L' defines instance member property 'a', so extended class 'X' must provide an initializer with this override. -tests/cases/compiler/mutuallyRecursiveInference.ts(10,5): error TS2610: Class 'L' defines instance member property 'b', so extended class 'X' must provide an initializer with this override. +tests/cases/compiler/mutuallyRecursiveInference.ts(9,5): error TS2610: Class 'L' defines instance member property 'a', so extended class 'X' must use 'declare' to make it ambient. +tests/cases/compiler/mutuallyRecursiveInference.ts(10,5): error TS2610: Class 'L' defines instance member property 'b', so extended class 'X' must use 'declare' to make it ambient. ==== tests/cases/compiler/mutuallyRecursiveInference.ts (2 errors) ==== @@ -13,10 +13,10 @@ tests/cases/compiler/mutuallyRecursiveInference.ts(10,5): error TS2610: Class 'L class X extends L { a: 'a' | 'b' ~ -!!! error TS2610: Class 'L' defines instance member property 'a', so extended class 'X' must provide an initializer with this override. +!!! error TS2610: Class 'L' defines instance member property 'a', so extended class 'X' must use 'declare' to make it ambient. b: number ~ -!!! error TS2610: Class 'L' defines instance member property 'b', so extended class 'X' must provide an initializer with this override. +!!! error TS2610: Class 'L' defines instance member property 'b', so extended class 'X' must use 'declare' to make it ambient. m2() { this.a } diff --git a/tests/baselines/reference/protectedMembers.errors.txt b/tests/baselines/reference/protectedMembers.errors.txt index 5a1fc2bfeb351..da2be41e9488e 100644 --- a/tests/baselines/reference/protectedMembers.errors.txt +++ b/tests/baselines/reference/protectedMembers.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/protectedMembers.ts(25,5): error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. +tests/cases/compiler/protectedMembers.ts(25,5): error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. tests/cases/compiler/protectedMembers.ts(40,4): error TS2445: Property 'x' is protected and only accessible within class 'C1' and its subclasses. tests/cases/compiler/protectedMembers.ts(41,4): error TS2445: Property 'f' is protected and only accessible within class 'C1' and its subclasses. tests/cases/compiler/protectedMembers.ts(42,4): error TS2445: Property 'sx' is protected and only accessible within class 'C1' and its subclasses. @@ -13,10 +13,10 @@ tests/cases/compiler/protectedMembers.ts(97,1): error TS2322: Type 'B1' is not a Property 'x' is protected but type 'B1' is not a class derived from 'A1'. tests/cases/compiler/protectedMembers.ts(98,1): error TS2322: Type 'A1' is not assignable to type 'B1'. Property 'x' is protected in type 'A1' but public in type 'B1'. -tests/cases/compiler/protectedMembers.ts(104,5): error TS2610: Class 'A2' defines instance member property 'x', so extended class 'B2' must provide an initializer with this override. +tests/cases/compiler/protectedMembers.ts(104,5): error TS2610: Class 'A2' defines instance member property 'x', so extended class 'B2' must use 'declare' to make it ambient. tests/cases/compiler/protectedMembers.ts(111,7): error TS2415: Class 'B3' incorrectly extends base class 'A3'. Property 'x' is protected in type 'B3' but public in type 'A3'. -tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Class 'A3' defines instance member property 'x', so extended class 'B3' must provide an initializer with this override. +tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Class 'A3' defines instance member property 'x', so extended class 'B3' must use 'declare' to make it ambient. ==== tests/cases/compiler/protectedMembers.ts (16 errors) ==== @@ -46,7 +46,7 @@ tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Class 'A3' defin class C3 extends C2 { x: number; ~ -!!! error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must provide an initializer with this override. +!!! error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. static sx: number; f() { return super.f(); @@ -153,7 +153,7 @@ tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Class 'A3' defin class B2 extends A2 { x; ~ -!!! error TS2610: Class 'A2' defines instance member property 'x', so extended class 'B2' must provide an initializer with this override. +!!! error TS2610: Class 'A2' defines instance member property 'x', so extended class 'B2' must use 'declare' to make it ambient. } class A3 { @@ -166,7 +166,7 @@ tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Class 'A3' defin !!! error TS2415: Property 'x' is protected in type 'B3' but public in type 'A3'. protected x; ~ -!!! error TS2610: Class 'A3' defines instance member property 'x', so extended class 'B3' must provide an initializer with this override. +!!! error TS2610: Class 'A3' defines instance member property 'x', so extended class 'B3' must use 'declare' to make it ambient. } \ No newline at end of file diff --git a/tests/baselines/reference/scopeTests.errors.txt b/tests/baselines/reference/scopeTests.errors.txt index 2457ba3912a61..cfafac1e1cada 100644 --- a/tests/baselines/reference/scopeTests.errors.txt +++ b/tests/baselines/reference/scopeTests.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/scopeTests.ts(2,7): error TS2415: Class 'D' incorrectly extends base class 'C'. Property 'v' is private in type 'C' but not in type 'D'. -tests/cases/compiler/scopeTests.ts(4,10): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. +tests/cases/compiler/scopeTests.ts(4,10): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must use 'declare' to make it ambient. ==== tests/cases/compiler/scopeTests.ts (2 errors) ==== @@ -12,7 +12,7 @@ tests/cases/compiler/scopeTests.ts(4,10): error TS2610: Class 'C' defines instan public v: number; public p: number ~ -!!! error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must provide an initializer with this override. +!!! error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must use 'declare' to make it ambient. constructor() { super() this.v = 1; diff --git a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt index 4541037baae14..44c8e7ba6a51d 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt @@ -1,7 +1,7 @@ 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 'C3'. Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(8,5): error TS2610: Class 'C3' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(8,5): error TS2610: Class 'C3' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (2 errors) ==== @@ -18,7 +18,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ~~~ -!!! error TS2610: Class 'C3' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. +!!! error TS2610: Class 'C3' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. } function f1(x: T, y: U) { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index e952bf31059ee..d1b6e7efe3aef 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt @@ -1,33 +1,33 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(37,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(42,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(37,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(42,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. 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(47,5): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'B1'. Type 'V' is not assignable to type 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(52,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(52,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. 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(57,5): error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'B1'. Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. Type 'Foo' is not assignable to type 'T'. 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. 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(62,5): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'B1'. Type 'V' is not assignable to type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. 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(67,5): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'B1'. Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. Type 'Foo' is not assignable to type 'U'. 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(72,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(72,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. 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'. 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 'B1'. Type 'V' is not assignable to type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (19 errors) ==== @@ -69,14 +69,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: Foo; foo: T; // ok ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. } class D2 extends B1 { [x: string]: Foo; foo: U; // ok ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. } class D3 extends B1 { @@ -88,14 +88,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'V' is not assignable to type 'Foo'. ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. } class D4 extends B1 { [x: string]: T; foo: T; // ok ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. } class D5 extends B1 { @@ -110,7 +110,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'Foo' is not assignable to type 'T'. !!! error TS2416: 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. } class D6 extends B1 { @@ -122,7 +122,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'V' is not assignable to type 'T'. ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. } class D7 extends B1 { @@ -137,14 +137,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'Foo' is not assignable to type 'U'. !!! error TS2416: 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. } class D8 extends B1 { [x: string]: U; foo: U; // ok ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. } class D9 extends B1 { @@ -156,5 +156,5 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D9' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'V' is not assignable to type 'U'. ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. +!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt index 4247c68cb876a..5ef5c6aa184ed 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt @@ -1,81 +1,81 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(63,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(63,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. 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(68,9): error TS2416: Property 'foo' in type 'D2' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(68,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. 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(73,9): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(73,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. 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(78,9): error TS2416: Property 'foo' in type 'D4' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(83,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(78,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(83,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. 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(88,9): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(88,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. 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(93,9): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(93,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. 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(98,9): error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(103,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(98,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(103,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. 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 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(115,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. 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(120,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(120,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. 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(125,9): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(125,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. 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(130,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(130,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. 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 'Base2'. 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(135,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(135,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. 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(140,9): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(140,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. 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(145,9): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(145,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. 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'. 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 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(155,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(150,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(155,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (42 errors) ==== @@ -143,7 +143,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: T ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. } class D2, U extends Foo, V extends Foo> extends Base { @@ -156,7 +156,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. } class D3, U extends Foo, V extends Foo> extends Base { @@ -169,7 +169,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'V' is not assignable to type 'T'. !!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. } class D4, U extends Foo, V extends Foo> extends Base { @@ -182,14 +182,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'T' is not assignable to type 'U'. !!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. } class D5, U extends Foo, V extends Foo> extends Base { [x: string]: U; foo: U ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. } class D6, U extends Foo, V extends Foo> extends Base { @@ -202,7 +202,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'V' is not assignable to type 'U'. !!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. } class D7, U extends Foo, V extends Foo> extends Base { @@ -215,7 +215,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'T' is not assignable to type 'V'. !!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. } class D8, U extends Foo, V extends Foo> extends Base { @@ -228,14 +228,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'U' is not assignable to type 'V'. !!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. } class D9, U extends Foo, V extends Foo> extends Base { [x: string]: V; foo: V ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. } } @@ -255,7 +255,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. } class D2, U extends Foo, V extends Foo> extends Base2 { @@ -264,7 +264,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. } class D3, U extends Foo, V extends Foo> extends Base2 { @@ -279,7 +279,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'V' is not assignable to type 'T'. !!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. } class D4, U extends Foo, V extends Foo> extends Base2 { @@ -288,7 +288,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. } class D5, U extends Foo, V extends Foo> extends Base2 { @@ -301,7 +301,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'T' is not assignable to type 'U'. !!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. } class D6, U extends Foo, V extends Foo> extends Base2 { @@ -316,7 +316,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'V' is not assignable to type 'U'. !!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. } class D7, U extends Foo, V extends Foo> extends Base2 { @@ -331,7 +331,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'U' is not assignable to type 'V'. !!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. } class D8, U extends Foo, V extends Foo> extends Base2 { @@ -346,13 +346,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'T' is not assignable to type 'V'. !!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. } class D9, U extends Foo, V extends Foo> extends Base2 { [x: string]: V; foo: V ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. +!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. } } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingTransitivity.errors.txt b/tests/baselines/reference/subtypingTransitivity.errors.txt index 1284422452565..c2ca02697cdd4 100644 --- a/tests/baselines/reference/subtypingTransitivity.errors.txt +++ b/tests/baselines/reference/subtypingTransitivity.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/subtypingTransitivity.ts(6,12): error TS2610: Class 'B' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. -tests/cases/compiler/subtypingTransitivity.ts(9,12): error TS2610: Class 'B' defines instance member property 'x', so extended class 'D2' must provide an initializer with this override. +tests/cases/compiler/subtypingTransitivity.ts(6,12): error TS2610: Class 'B' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. +tests/cases/compiler/subtypingTransitivity.ts(9,12): error TS2610: Class 'B' defines instance member property 'x', so extended class 'D2' must use 'declare' to make it ambient. ==== tests/cases/compiler/subtypingTransitivity.ts (2 errors) ==== @@ -10,12 +10,12 @@ tests/cases/compiler/subtypingTransitivity.ts(9,12): error TS2610: Class 'B' def class D extends B { public x: string; ~ -!!! error TS2610: Class 'B' defines instance member property 'x', so extended class 'D' must provide an initializer with this override. +!!! error TS2610: Class 'B' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. } class D2 extends B { public x: number; ~ -!!! error TS2610: Class 'B' defines instance member property 'x', so extended class 'D2' must provide an initializer with this override. +!!! error TS2610: Class 'B' defines instance member property 'x', so extended class 'D2' must use 'declare' to make it ambient. } var b: B; diff --git a/tests/baselines/reference/subtypingWithObjectMembers.errors.txt b/tests/baselines/reference/subtypingWithObjectMembers.errors.txt index 6690c442c81a7..b748602a82bf1 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers.errors.txt +++ b/tests/baselines/reference/subtypingWithObjectMembers.errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(13,5): error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(13,5): error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must use 'declare' to make it ambient. 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 'A'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(14,5): error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(23,5): error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(14,5): error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(23,5): error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must use 'declare' to make it ambient. 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 'A2'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(24,5): error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(33,5): error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(24,5): error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(33,5): error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must use 'declare' to make it ambient. 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 'A3'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(34,5): error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(44,9): error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(34,5): error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(44,9): error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must use 'declare' to make it ambient. 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 'A'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(45,9): error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(54,9): error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(45,9): error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(54,9): error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must use 'declare' to make it ambient. 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 'A2'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(55,9): error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(64,9): error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(55,9): error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(64,9): error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must use 'declare' to make it ambient. 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 'A3'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(65,9): error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(65,9): error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must use 'declare' to make it ambient. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts (18 errors) ==== @@ -39,13 +39,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { foo: Derived; // ok ~~~ -!!! error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must provide an initializer with this override. +!!! error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must use 'declare' to make it ambient. bar: string; // error ~~~ !!! error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'A'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~~~ -!!! error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must provide an initializer with this override. +!!! error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must use 'declare' to make it ambient. } class A2 { @@ -56,13 +56,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B2 extends A2 { 1: Derived; // ok ~ -!!! error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must provide an initializer with this override. +!!! error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must use 'declare' to make it ambient. 2: string; // error ~ !!! error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'A2'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~ -!!! error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must provide an initializer with this override. +!!! error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must use 'declare' to make it ambient. } class A3 { @@ -73,13 +73,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A3 { '1': Derived; // ok ~~~ -!!! error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must provide an initializer with this override. +!!! error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must use 'declare' to make it ambient. '2.0': string; // error ~~~~~ !!! error TS2416: Property ''2.0'' in type 'B3' is not assignable to the same property in base type 'A3'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~~~~~ -!!! error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must provide an initializer with this override. +!!! error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must use 'declare' to make it ambient. } module TwoLevels { @@ -91,13 +91,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { foo: Derived2; // ok ~~~ -!!! error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must provide an initializer with this override. +!!! error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must use 'declare' to make it ambient. bar: string; // error ~~~ !!! error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'A'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~~~ -!!! error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must provide an initializer with this override. +!!! error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must use 'declare' to make it ambient. } class A2 { @@ -108,13 +108,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B2 extends A2 { 1: Derived2; // ok ~ -!!! error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must provide an initializer with this override. +!!! error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must use 'declare' to make it ambient. 2: string; // error ~ !!! error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'A2'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~ -!!! error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must provide an initializer with this override. +!!! error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must use 'declare' to make it ambient. } class A3 { @@ -125,12 +125,12 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A3 { '1': Derived2; // ok ~~~ -!!! error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must provide an initializer with this override. +!!! error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must use 'declare' to make it ambient. '2.0': string; // error ~~~~~ !!! error TS2416: Property ''2.0'' in type 'B3' is not assignable to the same property in base type 'A3'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~~~~~ -!!! error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must provide an initializer with this override. +!!! error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must use 'declare' to make it ambient. } } \ No newline at end of file diff --git a/tests/baselines/reference/tsxGenericAttributesType5.errors.txt b/tests/baselines/reference/tsxGenericAttributesType5.errors.txt index 42f10f91f7fa2..5143478df0c47 100644 --- a/tests/baselines/reference/tsxGenericAttributesType5.errors.txt +++ b/tests/baselines/reference/tsxGenericAttributesType5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must provide an initializer with this override. +tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must use 'declare' to make it ambient. ==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component class B extends React.Component { props: U; ~~~~~ -!!! error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must provide an initializer with this override. +!!! error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must use 'declare' to make it ambient. render() { return ; } diff --git a/tests/baselines/reference/tsxGenericAttributesType6.errors.txt b/tests/baselines/reference/tsxGenericAttributesType6.errors.txt index af26e4a25b933..e1933e9a5c670 100644 --- a/tests/baselines/reference/tsxGenericAttributesType6.errors.txt +++ b/tests/baselines/reference/tsxGenericAttributesType6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must provide an initializer with this override. +tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must use 'declare' to make it ambient. ==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component class B extends React.Component { props: U; ~~~~~ -!!! error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must provide an initializer with this override. +!!! error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must use 'declare' to make it ambient. render() { return ; } diff --git a/tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt b/tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt index 2bba64a42e2c6..eb283445e2327 100644 --- a/tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt +++ b/tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt @@ -1,25 +1,25 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(8,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D0' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(12,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'DA' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(16,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(20,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1A' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(25,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(29,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2A' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(34,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(38,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3A' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(43,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(47,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(52,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(56,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(61,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(68,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(73,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D10' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(78,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D11' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(86,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D12' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(95,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D13' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(100,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D14' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(105,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D15' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(114,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D16' must provide an initializer with this override. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(119,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D17' must provide an initializer with this override. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(8,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D0' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(12,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'DA' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(16,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(20,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1A' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(25,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(29,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2A' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(34,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(38,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3A' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(43,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(47,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(52,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(56,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(61,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(68,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(73,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D10' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(78,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D11' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(86,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D12' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(95,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D13' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(100,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D14' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(105,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D15' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(114,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D16' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(119,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D17' must use 'declare' to make it ambient. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts (22 errors) ==== @@ -32,84 +32,84 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedI class D0 extends Base { foo: any; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D0' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D0' must use 'declare' to make it ambient. } class DA extends Base { foo: typeof undefined; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'DA' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'DA' must use 'declare' to make it ambient. } class D1 extends Base { foo: string; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. } class D1A extends Base { foo: String; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1A' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1A' must use 'declare' to make it ambient. } class D2 extends Base { foo: number; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. } class D2A extends Base { foo: Number; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2A' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2A' must use 'declare' to make it ambient. } class D3 extends Base { foo: boolean; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. } class D3A extends Base { foo: Boolean; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3A' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3A' must use 'declare' to make it ambient. } class D4 extends Base { foo: RegExp; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. } class D5 extends Base { foo: Date; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. } class D6 extends Base { foo: number[]; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. } class D7 extends Base { foo: { bar: number }; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. } class D8 extends Base { foo: D7; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. } interface I1 { @@ -118,21 +118,21 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedI class D9 extends Base { foo: I1; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. } class D10 extends Base { foo: () => number; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D10' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D10' must use 'declare' to make it ambient. } enum E { A } class D11 extends Base { foo: E; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D11' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D11' must use 'declare' to make it ambient. } function f() { } @@ -142,7 +142,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedI class D12 extends Base { foo: typeof f; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D12' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D12' must use 'declare' to make it ambient. } @@ -153,21 +153,21 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedI class D13 extends Base { foo: typeof c; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D13' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D13' must use 'declare' to make it ambient. } class D14 extends Base { foo: T; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D14' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D14' must use 'declare' to make it ambient. } class D15 extends Base { foo: U; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D15' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D15' must use 'declare' to make it ambient. } //class D15 extends Base { @@ -178,13 +178,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedI class D16 extends Base { foo: Object; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D16' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D16' must use 'declare' to make it ambient. } class D17 extends Base { foo: {}; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D17' must provide an initializer with this override. +!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D17' must use 'declare' to make it ambient. } \ No newline at end of file From 2e5f57ce2b94bb08c29f58bde252c858a9e753f4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 16 Sep 2019 16:18:52 -0700 Subject: [PATCH 06/17] Improve error wording --- src/compiler/checker.ts | 4 +- src/compiler/diagnosticMessages.json | 2 +- .../apparentTypeSubtyping.errors.txt | 8 +- .../apparentTypeSupertype.errors.txt | 4 +- ...baseClassImprovedMismatchErrors.errors.txt | 4 +- .../classIsSubtypeOfBaseType.errors.txt | 8 +- ...declarationEmitProtectedMembers.errors.txt | 4 +- ...dClassOverridesProtectedMembers.errors.txt | 8 +- ...ClassOverridesProtectedMembers2.errors.txt | 8 +- ...ClassOverridesProtectedMembers3.errors.txt | 8 +- ...ClassOverridesProtectedMembers4.errors.txt | 8 +- ...ivedClassOverridesPublicMembers.errors.txt | 8 +- ...vedClassOverridesWithoutSubtype.errors.txt | 4 +- .../reference/derivedClassWithAny.errors.txt | 8 +- .../derivedGenericClassWithAny.errors.txt | 8 +- ...ninitializedPropertyDeclaration.errors.txt | 12 +-- .../genericPrototypeProperty2.errors.txt | 8 +- .../genericPrototypeProperty3.errors.txt | 8 +- ...aceExtendingClassWithProtecteds.errors.txt | 4 +- .../reference/inheritance.errors.txt | 4 +- ...emberPropertyOverridingAccessor.errors.txt | 4 +- ...emberPropertyOverridingProperty.errors.txt | 4 +- .../instanceSubtypeCheck2.errors.txt | 4 +- ...erfaceExtendsObjectIntersection.errors.txt | 28 +++--- ...ExtendsObjectIntersectionErrors.errors.txt | 20 ++--- .../reference/multipleInheritance.errors.txt | 4 +- .../mutuallyRecursiveInference.errors.txt | 8 +- .../reference/protectedMembers.errors.txt | 12 +-- .../baselines/reference/scopeTests.errors.txt | 4 +- .../subtypesOfTypeParameter.errors.txt | 4 +- ...OfTypeParameterWithConstraints4.errors.txt | 36 ++++---- ...rameterWithRecursiveConstraints.errors.txt | 72 +++++++-------- .../subtypingTransitivity.errors.txt | 8 +- .../subtypingWithObjectMembers.errors.txt | 48 +++++----- .../tsxGenericAttributesType5.errors.txt | 4 +- .../tsxGenericAttributesType6.errors.txt | 4 +- .../undefinedIsSubtypeOfEverything.errors.txt | 88 +++++++++---------- 37 files changed, 241 insertions(+), 241 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1a26abaaa4abf..0b1e43dc205ba 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29534,8 +29534,8 @@ namespace ts { || !isIdentifier(propName) || !strictNullChecks || !isPropertyInitializedInConstructor(propName, type, constructor)) { - const errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_so_extended_class_2_must_use_declare_to_make_it_ambient; - error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + const errorMessage = Diagnostics.Property_0_will_overwrite_the_base_property_in_1_Add_a_declare_modifier_or_an_initializer_to_avoid_this; + error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, symbolToString(base), typeToString(baseType)); } } continue; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b0f8ca8e24ed2..baa77494e818b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2204,7 +2204,7 @@ "category": "Error", "code": 2609 }, - "Class '{0}' defines instance member property '{1}', so extended class '{2}' must use 'declare' to make it ambient.": { + "Property '{0}' will overwrite the base property in '{1}'. Add a 'declare' modifier or an initializer to avoid this.": { "category": "Error", "code": 2610 }, diff --git a/tests/baselines/reference/apparentTypeSubtyping.errors.txt b/tests/baselines/reference/apparentTypeSubtyping.errors.txt index e4088efe246a7..9f43225eb1594 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.errors.txt +++ b/tests/baselines/reference/apparentTypeSubtyping.errors.txt @@ -1,8 +1,8 @@ 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 'Base'. 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 TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(20,5): error TS2610: Class 'Base2' defines instance member property 'x', so extended class 'Derived2' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(10,5): error TS2610: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(20,5): error TS2610: Property 'x' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts (3 errors) ==== @@ -21,7 +21,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi !!! 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. ~ -!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class Base2 { @@ -33,5 +33,5 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi class Derived2 extends Base2 { // error because of the prototype's not matching, not because of the instance side x: U; ~ -!!! error TS2610: Class 'Base2' defines instance member property 'x', so extended class 'Derived2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file diff --git a/tests/baselines/reference/apparentTypeSupertype.errors.txt b/tests/baselines/reference/apparentTypeSupertype.errors.txt index 5d13848277882..1dde3b891f812 100644 --- a/tests/baselines/reference/apparentTypeSupertype.errors.txt +++ b/tests/baselines/reference/apparentTypeSupertype.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty 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 TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts(10,5): error TS2610: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (2 errors) ==== @@ -22,5 +22,5 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty !!! 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. ~ -!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file diff --git a/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt b/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt index b654bfa37d072..4bdf83b31c789 100644 --- a/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt +++ b/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2416: Prop 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'. -tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2610: Class 'Base' defines instance member property 'n', so extended class 'Derived' must use 'declare' to make it ambient. +tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2610: Property 'n' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/compiler/baseClassImprovedMismatchErrors.ts(9,5): error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type 'Base'. Type '() => string | number' is not assignable to type '() => number'. Type 'string | number' is not assignable to type 'number'. @@ -41,7 +41,7 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(15,5): error TS2416: Pro !!! error TS2416: Type 'string | Derived' is not assignable to type 'string | Base'. !!! error TS2416: Type 'Derived' is not assignable to type 'string | Base'. ~ -!!! error TS2610: Class 'Base' defines instance member property 'n', so extended class 'Derived' must use 'declare' to make it ambient. +!!! error TS2610: Property 'n' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. fn() { ~~ !!! error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type 'Base'. diff --git a/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt b/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt index 86370198f2c6e..f8369af4ad403 100644 --- a/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt +++ b/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(6,5): error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived' must use 'declare' to make it ambient. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(6,5): error TS2610: Property 'foo' will overwrite the base property in 'Base<{ bar: string; }>'. Add a 'declare' modifier or an initializer to avoid this. 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 'Base<{ 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(12,5): error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived2' must use 'declare' to make it ambient. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(12,5): error TS2610: Property 'foo' will overwrite the base property in 'Base<{ bar: string; }>'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts (3 errors) ==== @@ -13,7 +13,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla class Derived extends Base<{ bar: string; }> { foo: { ~~~ -!!! error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<{ bar: string; }>'. Add a 'declare' modifier or an initializer to avoid this. bar: string; baz: number; // ok } } @@ -25,7 +25,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla !!! 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; }'. ~~~ -!!! error TS2610: Class 'Base<{ bar: string; }>' defines instance member property 'foo', so extended class 'Derived2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<{ bar: string; }>'. Add a 'declare' modifier or an initializer to avoid this. bar?: string; // error } } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt b/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt index 803f761654333..5adfa76f4f627 100644 --- a/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt +++ b/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/declarationEmitProtectedMembers.ts(34,5): error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. +tests/cases/compiler/declarationEmitProtectedMembers.ts(34,5): error TS2610: Property 'x' will overwrite the base property in 'C2'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/compiler/declarationEmitProtectedMembers.ts (1 errors) ==== @@ -37,7 +37,7 @@ tests/cases/compiler/declarationEmitProtectedMembers.ts(34,5): error TS2610: Cla class C3 extends C2 { x: number; ~ -!!! error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'C2'. Add a 'declare' modifier or an initializer to avoid this. static sx: number; f() { return super.f(); diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt index cbf6d7f53c228..a7c03264131bb 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(21,15): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(25,15): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(21,15): error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(25,15): error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts (2 errors) ==== @@ -25,13 +25,13 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived extends Base { protected a: typeof y; ~ -!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. +!!! error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. protected b(a: typeof y) { } protected get c() { return y; } protected set c(v: typeof y) { } protected d: (a: typeof y) => void; ~ -!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. +!!! error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. protected static r: typeof y; protected static s(a: typeof y) { } diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt index b739769498fbf..816f3b4df5d25 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(22,5): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(26,5): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(22,5): error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(26,5): error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts (2 errors) ==== @@ -26,13 +26,13 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived extends Base { a: typeof y; ~ -!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. +!!! error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. b(a: typeof y) { } get c() { return y; } set c(v: typeof y) { } d: (a: typeof y) => void; ~ -!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. +!!! error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. static r: typeof y; static s(a: typeof y) { } diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt index 4c74d97f040a9..1be0509e6524d 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(22,7): error TS2415: Class 'Derived1' incorrectly extends base class 'Base'. Property 'a' is protected in type 'Derived1' but public in type 'Base'. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(23,15): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(23,15): error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(27,7): error TS2415: Class 'Derived2' incorrectly extends base class 'Base'. Property 'b' is protected in type 'Derived2' but public in type 'Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(32,7): error TS2415: Class 'Derived3' incorrectly extends base class 'Base'. @@ -9,7 +9,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve Property 'c' is protected in type 'Derived4' but public in type 'Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(42,7): error TS2415: Class 'Derived5' incorrectly extends base class 'Base'. Property 'd' is protected in type 'Derived5' but public in type 'Base'. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(43,15): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived5' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(43,15): error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(47,7): error TS2417: Class static side 'typeof Derived6' incorrectly extends base class static side 'typeof Base'. Property 'r' is protected in type 'typeof Derived6' but public in type 'typeof Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(52,7): error TS2417: Class static side 'typeof Derived7' incorrectly extends base class static side 'typeof Base'. @@ -50,7 +50,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve !!! error TS2415: Property 'a' is protected in type 'Derived1' but public in type 'Base'. protected a: typeof x; ~ -!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must use 'declare' to make it ambient. +!!! error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. constructor(a: typeof x) { super(a); } } @@ -84,7 +84,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve !!! error TS2415: Property 'd' is protected in type 'Derived5' but public in type 'Base'. protected d: (a: typeof x) => void ; ~ -!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived5' must use 'declare' to make it ambient. +!!! error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. constructor(a: typeof x) { super(a); } } diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt index 9f401ea1e5668..2d11066559826 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(9,12): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(9,12): error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(12,7): error TS2415: Class 'Derived2' incorrectly extends base class 'Derived1'. Property 'a' is protected in type 'Derived2' but public in type 'Derived1'. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(13,15): error TS2610: Class 'Derived1' defines instance member property 'a', so extended class 'Derived2' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(13,15): error TS2610: Property 'a' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts (3 errors) ==== @@ -15,7 +15,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived1 extends Base { public a: typeof x; ~ -!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived1' must use 'declare' to make it ambient. +!!! error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class Derived2 extends Derived1 { @@ -24,5 +24,5 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve !!! error TS2415: Property 'a' is protected in type 'Derived2' but public in type 'Derived1'. protected a: typeof x; // Error, parent was public ~ -!!! error TS2610: Class 'Derived1' defines instance member property 'a', so extended class 'Derived2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'a' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt b/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt index 145350ee604f9..45511c1a2c013 100644 --- a/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesPublicMembers.errors.txt @@ -2,10 +2,10 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(13,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(14,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(21,5): error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(21,5): error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(24,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(25,5): error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(25,5): error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(29,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(30,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -41,7 +41,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived extends Base { a: typeof y; ~ -!!! error TS2610: Class 'Base' defines instance member property 'a', so extended class 'Derived' must use 'declare' to make it ambient. +!!! error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. b(a: typeof y) { } get c() { return y; } ~ @@ -51,7 +51,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. d: (a: typeof y) => void; ~ -!!! error TS2610: Class 'Base' defines instance member property 'd', so extended class 'Derived' must use 'declare' to make it ambient. +!!! error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. static r: typeof y; static s(a: typeof y) { } diff --git a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt index 7a7633d461c6e..8f65f436dcac8 100644 --- a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesWithoutSubtype.ts(8,5): error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesWithoutSubtype.ts(8,5): error TS2610: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesWithoutSubtype.ts (1 errors) ==== @@ -11,7 +11,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived extends Base { x: { ~ -!!! error TS2610: Class 'Base' defines instance member property 'x', so extended class 'Derived' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. foo: any; } } diff --git a/tests/baselines/reference/derivedClassWithAny.errors.txt b/tests/baselines/reference/derivedClassWithAny.errors.txt index c2037c529cfb0..5f8a219b58eb2 100644 --- a/tests/baselines/reference/derivedClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedClassWithAny.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(18,5): error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(18,5): error TS2610: Property 'x' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(19,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(27,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(37,5): error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(37,5): error TS2610: Property 'x' will overwrite the base property in 'D'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(38,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(44,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(57,1): error TS2322: Type 'E' is not assignable to type 'C'. @@ -35,7 +35,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit class D extends C { x: any; ~ -!!! error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. get X(): any { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -60,7 +60,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit class E extends D { x: string; ~ -!!! error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'D'. Add a 'declare' modifier or an initializer to avoid this. get X(): string{ return ''; } ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt index d5dc9585271d2..6d32d3f814739 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(10,5): error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(10,5): error TS2610: Property 'x' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(19,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(29,5): error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must use 'declare' to make it ambient. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(29,5): error TS2610: Property 'x' will overwrite the base property in 'D'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,18): error TS2322: Type '""' is not assignable to type 'T'. '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. @@ -27,7 +27,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC class D extends C { x: any; ~ -!!! error TS2610: Class 'C' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. get X(): any { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -52,7 +52,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC class E extends D { x: T; ~ -!!! error TS2610: Class 'D' defines instance member property 'x', so extended class 'E' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'D'. Add a 'declare' modifier or an initializer to avoid this. get X(): T { return ''; } // error ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt index aa9f4b955938d..737c83bd0ce8c 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(6,5): error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must use 'declare' to make it ambient. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(6,5): error TS2610: Property 'property' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,5): error TS1031: 'declare' modifier cannot appear on a class element. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(16,13): error TS2611: Ambient property declarations must override a property in a base class. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(17,24): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(20,13): error TS2611: Ambient property declarations must override a property in a base class. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(24,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must use 'declare' to make it ambient. -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(39,5): error TS2610: Class 'E' defines instance member property 'p1', so extended class 'F' must use 'declare' to make it ambient. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2610: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(39,5): error TS2610: Property 'p1' will overwrite the base property in 'E'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (9 errors) ==== @@ -17,7 +17,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP class B extends A { property: any; // error ~~~~~~~~ -!!! error TS2610: Class 'A' defines instance member property 'property', so extended class 'B' must use 'declare' to make it ambient. +!!! error TS2610: Property 'property' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. } class BD extends A { declare property: any; // ok because it's implicitly initialised @@ -52,7 +52,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP ~ !!! error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. ~ -!!! error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must use 'declare' to make it ambient. +!!! error TS2610: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. } class DD extends C { declare p: 'bye'; // ok @@ -66,7 +66,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP class F extends E { p1!: 'z' ~~ -!!! error TS2610: Class 'E' defines instance member property 'p1', so extended class 'F' must use 'declare' to make it ambient. +!!! error TS2610: Property 'p1' will overwrite the base property in 'E'. Add a 'declare' modifier or an initializer to avoid this. declare p2: 'alpha' } diff --git a/tests/baselines/reference/genericPrototypeProperty2.errors.txt b/tests/baselines/reference/genericPrototypeProperty2.errors.txt index 117cc90b99fae..2d27cf0fc4e72 100644 --- a/tests/baselines/reference/genericPrototypeProperty2.errors.txt +++ b/tests/baselines/reference/genericPrototypeProperty2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/genericPrototypeProperty2.ts(7,5): error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must use 'declare' to make it ambient. -tests/cases/compiler/genericPrototypeProperty2.ts(14,5): error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must use 'declare' to make it ambient. +tests/cases/compiler/genericPrototypeProperty2.ts(7,5): error TS2610: Property 'target' will overwrite the base property in 'BaseEvent'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/compiler/genericPrototypeProperty2.ts(14,5): error TS2610: Property 't' will overwrite the base property in 'BaseEventWrapper'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/compiler/genericPrototypeProperty2.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/genericPrototypeProperty2.ts(14,5): error TS2610: Class 'Ba class MyEvent extends BaseEvent { target: T; ~~~~~~ -!!! error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must use 'declare' to make it ambient. +!!! error TS2610: Property 'target' will overwrite the base property in 'BaseEvent'. Add a 'declare' modifier or an initializer to avoid this. } class BaseEventWrapper { t: BaseEvent; @@ -20,5 +20,5 @@ tests/cases/compiler/genericPrototypeProperty2.ts(14,5): error TS2610: Class 'Ba class MyEventWrapper extends BaseEventWrapper { t: MyEvent; // any satisfies constraint and passes assignability check between 'target' properties ~ -!!! error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must use 'declare' to make it ambient. +!!! error TS2610: Property 't' will overwrite the base property in 'BaseEventWrapper'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file diff --git a/tests/baselines/reference/genericPrototypeProperty3.errors.txt b/tests/baselines/reference/genericPrototypeProperty3.errors.txt index ca3398d6722d3..c12e29d3da0cc 100644 --- a/tests/baselines/reference/genericPrototypeProperty3.errors.txt +++ b/tests/baselines/reference/genericPrototypeProperty3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/genericPrototypeProperty3.ts(6,5): error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must use 'declare' to make it ambient. -tests/cases/compiler/genericPrototypeProperty3.ts(13,5): error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must use 'declare' to make it ambient. +tests/cases/compiler/genericPrototypeProperty3.ts(6,5): error TS2610: Property 'target' will overwrite the base property in 'BaseEvent'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/compiler/genericPrototypeProperty3.ts(13,5): error TS2610: Property 't' will overwrite the base property in 'BaseEventWrapper'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/compiler/genericPrototypeProperty3.ts (2 errors) ==== @@ -10,7 +10,7 @@ tests/cases/compiler/genericPrototypeProperty3.ts(13,5): error TS2610: Class 'Ba class MyEvent extends BaseEvent { // T is instantiated to any in the prototype, which is assignable to {} target: T; ~~~~~~ -!!! error TS2610: Class 'BaseEvent' defines instance member property 'target', so extended class 'MyEvent' must use 'declare' to make it ambient. +!!! error TS2610: Property 'target' will overwrite the base property in 'BaseEvent'. Add a 'declare' modifier or an initializer to avoid this. } class BaseEventWrapper { t: BaseEvent; @@ -19,5 +19,5 @@ tests/cases/compiler/genericPrototypeProperty3.ts(13,5): error TS2610: Class 'Ba class MyEventWrapper extends BaseEventWrapper { t: MyEvent; ~ -!!! error TS2610: Class 'BaseEventWrapper' defines instance member property 't', so extended class 'MyEventWrapper' must use 'declare' to make it ambient. +!!! error TS2610: Property 't' will overwrite the base property in 'BaseEventWrapper'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt index 98aee8dd231f7..d8cb657aa4305 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt @@ -10,7 +10,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte Property 'y' is missing in type 'Bar5' but required in type 'I'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(29,7): error TS2420: Class 'Bar6' incorrectly implements interface 'I'. Property 'y' is protected in type 'Bar6' but public in type 'I'. -tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(38,5): error TS2610: Class 'Foo' defines instance member property 'x', so extended class 'Bar8' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(38,5): error TS2610: Property 'x' will overwrite the base property in 'Foo'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts (7 errors) ==== @@ -73,7 +73,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte class Bar8 extends Foo implements I { x: string; ~ -!!! error TS2610: Class 'Foo' defines instance member property 'x', so extended class 'Bar8' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'Foo'. Add a 'declare' modifier or an initializer to avoid this. y: number; } \ No newline at end of file diff --git a/tests/baselines/reference/inheritance.errors.txt b/tests/baselines/reference/inheritance.errors.txt index 9b589f51a0b0e..45a1dbfc5666e 100644 --- a/tests/baselines/reference/inheritance.errors.txt +++ b/tests/baselines/reference/inheritance.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/inheritance.ts(22,12): error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must use 'declare' to make it ambient. +tests/cases/compiler/inheritance.ts(22,12): error TS2610: Property 'y' will overwrite the base property in 'N'. Add a 'declare' modifier or an initializer to avoid this. 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 'Good'. Type '(n: number) => number' is not assignable to type '() => number'. @@ -28,7 +28,7 @@ tests/cases/compiler/inheritance.ts(32,12): error TS2416: Property 'g' in type ' class ND extends N { // any is assignable to number public y; ~ -!!! error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must use 'declare' to make it ambient. +!!! error TS2610: Property 'y' will overwrite the base property in 'N'. Add a 'declare' modifier or an initializer to avoid this. } class Good { diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt index 18f70505450b4..3996eaf15c34b 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(6,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(12,5): error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must use 'declare' to make it ambient. +tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(12,5): error TS2610: Property 'x' will overwrite the base property in 'a'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts (3 errors) ==== @@ -21,5 +21,5 @@ tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(12,5): error class b extends a { x: () => string; ~ -!!! error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'a'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt index ee3da3f95a37d..79b3e6a8f1ea8 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts(6,5): error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must use 'declare' to make it ambient. +tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts(6,5): error TS2610: Property 'x' will overwrite the base property in 'a'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts (1 errors) ==== @@ -9,5 +9,5 @@ tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts(6,5): error class b extends a { x: () => string; ~ -!!! error TS2610: Class 'a' defines instance member property 'x', so extended class 'b' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'a'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file diff --git a/tests/baselines/reference/instanceSubtypeCheck2.errors.txt b/tests/baselines/reference/instanceSubtypeCheck2.errors.txt index 4640ae46fc29f..1d3622f49e79f 100644 --- a/tests/baselines/reference/instanceSubtypeCheck2.errors.txt +++ b/tests/baselines/reference/instanceSubtypeCheck2.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2416: Property 'x' in type 'C2' is not assignable to the same property in base type 'C1'. Type 'string' is not assignable to type 'C2'. -tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2610: Class 'C1' defines instance member property 'x', so extended class 'C2' must use 'declare' to make it ambient. +tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2610: Property 'x' will overwrite the base property in 'C1'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/compiler/instanceSubtypeCheck2.ts (2 errors) ==== @@ -14,5 +14,5 @@ tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2610: Class 'C1' !!! error TS2416: Property 'x' in type 'C2' is not assignable to the same property in base type 'C1'. !!! error TS2416: Type 'string' is not assignable to type 'C2'. ~ -!!! error TS2610: Class 'C1' defines instance member property 'x', so extended class 'C2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'C1'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt index 4778cd7e0f2f2..f23383cda97cc 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt +++ b/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(20,38): error TS2610: Class 'I1' defines instance member property 'x', so extended class 'C1' must use 'declare' to make it ambient. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(21,38): error TS2610: Class 'I2' defines instance member property 'x', so extended class 'C2' must use 'declare' to make it ambient. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(22,38): error TS2610: Class 'I3' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(23,38): error TS2610: Class 'I4' defines instance member property 'x', so extended class 'C4' must use 'declare' to make it ambient. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(24,38): error TS2610: Class 'I5' defines instance member property 'x', so extended class 'C5' must use 'declare' to make it ambient. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(25,38): error TS2610: Class 'I6' defines instance member property 'x', so extended class 'C6' must use 'declare' to make it ambient. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(26,38): error TS2610: Class 'I7' defines instance member property 'x', so extended class 'C7' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(20,38): error TS2610: Property 'x' will overwrite the base property in 'I1'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(21,38): error TS2610: Property 'x' will overwrite the base property in 'I2'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(22,38): error TS2610: Property 'x' will overwrite the base property in 'I3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(23,38): error TS2610: Property 'x' will overwrite the base property in 'I4'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(24,38): error TS2610: Property 'x' will overwrite the base property in 'I5'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(25,38): error TS2610: Property 'x' will overwrite the base property in 'I6'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(26,38): error TS2610: Property 'x' will overwrite the base property in 'I7'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts (7 errors) ==== @@ -29,25 +29,25 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI class C1 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I1' defines instance member property 'x', so extended class 'C1' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'I1'. Add a 'declare' modifier or an initializer to avoid this. class C2 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I2' defines instance member property 'x', so extended class 'C2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'I2'. Add a 'declare' modifier or an initializer to avoid this. class C3 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I3' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'I3'. Add a 'declare' modifier or an initializer to avoid this. class C4 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I4' defines instance member property 'x', so extended class 'C4' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'I4'. Add a 'declare' modifier or an initializer to avoid this. class C5 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I5' defines instance member property 'x', so extended class 'C5' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'I5'. Add a 'declare' modifier or an initializer to avoid this. class C6 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I6' defines instance member property 'x', so extended class 'C6' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'I6'. Add a 'declare' modifier or an initializer to avoid this. class C7 extends Constructor() { x: string } ~ -!!! error TS2610: Class 'I7' defines instance member property 'x', so extended class 'C7' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'I7'. Add a 'declare' modifier or an initializer to avoid this. declare function fx(x: string): string; declare class CX { a: number } diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt index 0f4a62fd786ac..88f9150adc11d 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt @@ -16,19 +16,19 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI 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 'T1'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(16,38): error TS2610: Class 'T1' defines instance member property 'a', so extended class 'C1' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(16,38): error TS2610: Property 'a' will overwrite the base property in 'T1'. Add a 'declare' modifier or an initializer to avoid this. 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 'T2'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,38): error TS2610: Class 'T2' defines instance member property 'b', so extended class 'C2' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,38): error TS2610: Property 'b' will overwrite the base property in 'T2'. Add a 'declare' modifier or an initializer to avoid this. 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(18,38): error TS2610: Class 'number[]' defines instance member property 'length', so extended class 'C3' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(18,38): error TS2610: Property 'length' will overwrite the base property in 'number[]'. Add a 'declare' modifier or an initializer to avoid this. 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, number]'. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,38): error TS2610: Class '[string, number]' defines instance member property '0', so extended class 'C4' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,38): error TS2610: Property '0' will overwrite the base property in '[string, number]'. Add a 'declare' modifier or an initializer to avoid this. 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 'T5'. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(20,38): error TS2610: Class 'T5' defines instance member property 'c', so extended class 'C5' must use 'declare' to make it ambient. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(20,38): error TS2610: Property 'c' will overwrite the base property in 'T5'. Add a 'declare' modifier or an initializer to avoid this. 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'. @@ -102,31 +102,31 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI !!! error TS2416: Property 'a' in type 'C1' is not assignable to the same property in base type 'T1'. !!! error TS2416: Type 'string' is not assignable to type 'number'. ~ -!!! error TS2610: Class 'T1' defines instance member property 'a', so extended class 'C1' must use 'declare' to make it ambient. +!!! error TS2610: Property 'a' will overwrite the base property in 'T1'. Add a 'declare' modifier or an initializer to avoid this. class C2 extends Constructor() { b: string } ~ !!! error TS2416: Property 'b' in type 'C2' is not assignable to the same property in base type 'T2'. !!! error TS2416: Type 'string' is not assignable to type 'number'. ~ -!!! error TS2610: Class 'T2' defines instance member property 'b', so extended class 'C2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'b' will overwrite the base property in 'T2'. Add a 'declare' modifier or an initializer to avoid this. class C3 extends Constructor() { length: string } ~~~~~~ !!! 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'. ~~~~~~ -!!! error TS2610: Class 'number[]' defines instance member property 'length', so extended class 'C3' must use 'declare' to make it ambient. +!!! error TS2610: Property 'length' will overwrite the base property in 'number[]'. Add a 'declare' modifier or an initializer to avoid this. class C4 extends Constructor() { 0: number } ~ !!! error TS2416: Property '0' in type 'C4' is not assignable to the same property in base type '[string, number]'. !!! error TS2416: Type 'number' is not assignable to type 'string'. ~ -!!! error TS2610: Class '[string, number]' defines instance member property '0', so extended class 'C4' must use 'declare' to make it ambient. +!!! error TS2610: Property '0' will overwrite the base property in '[string, number]'. Add a 'declare' modifier or an initializer to avoid this. class C5 extends Constructor() { c: number } ~ !!! error TS2416: Property 'c' in type 'C5' is not assignable to the same property in base type 'T5'. !!! error TS2416: Type 'number' is not assignable to type 'string'. ~ -!!! error TS2610: Class 'T5' defines instance member property 'c', so extended class 'C5' must use 'declare' to make it ambient. +!!! error TS2610: Property 'c' will overwrite the base property in 'T5'. Add a 'declare' modifier or an initializer to avoid this. declare class CX { static a: string } declare enum EX { A, B, C } diff --git a/tests/baselines/reference/multipleInheritance.errors.txt b/tests/baselines/reference/multipleInheritance.errors.txt index 0f4e79738e9e6..2e3788c895de9 100644 --- a/tests/baselines/reference/multipleInheritance.errors.txt +++ b/tests/baselines/reference/multipleInheritance.errors.txt @@ -1,6 +1,6 @@ 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(26,12): error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must use 'declare' to make it ambient. +tests/cases/compiler/multipleInheritance.ts(26,12): error TS2610: Property 'y' will overwrite the base property in 'N'. Add a 'declare' modifier or an initializer to avoid this. 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 'Good'. Type '(n: number) => number' is not assignable to type '() => number'. @@ -38,7 +38,7 @@ tests/cases/compiler/multipleInheritance.ts(36,12): error TS2416: Property 'g' i class ND extends N { // any is assignable to number public y; ~ -!!! error TS2610: Class 'N' defines instance member property 'y', so extended class 'ND' must use 'declare' to make it ambient. +!!! error TS2610: Property 'y' will overwrite the base property in 'N'. Add a 'declare' modifier or an initializer to avoid this. } class Good { diff --git a/tests/baselines/reference/mutuallyRecursiveInference.errors.txt b/tests/baselines/reference/mutuallyRecursiveInference.errors.txt index f6b5d58430f4b..cdb3abea28fee 100644 --- a/tests/baselines/reference/mutuallyRecursiveInference.errors.txt +++ b/tests/baselines/reference/mutuallyRecursiveInference.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/mutuallyRecursiveInference.ts(9,5): error TS2610: Class 'L' defines instance member property 'a', so extended class 'X' must use 'declare' to make it ambient. -tests/cases/compiler/mutuallyRecursiveInference.ts(10,5): error TS2610: Class 'L' defines instance member property 'b', so extended class 'X' must use 'declare' to make it ambient. +tests/cases/compiler/mutuallyRecursiveInference.ts(9,5): error TS2610: Property 'a' will overwrite the base property in 'L'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/compiler/mutuallyRecursiveInference.ts(10,5): error TS2610: Property 'b' will overwrite the base property in 'L'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/compiler/mutuallyRecursiveInference.ts (2 errors) ==== @@ -13,10 +13,10 @@ tests/cases/compiler/mutuallyRecursiveInference.ts(10,5): error TS2610: Class 'L class X extends L { a: 'a' | 'b' ~ -!!! error TS2610: Class 'L' defines instance member property 'a', so extended class 'X' must use 'declare' to make it ambient. +!!! error TS2610: Property 'a' will overwrite the base property in 'L'. Add a 'declare' modifier or an initializer to avoid this. b: number ~ -!!! error TS2610: Class 'L' defines instance member property 'b', so extended class 'X' must use 'declare' to make it ambient. +!!! error TS2610: Property 'b' will overwrite the base property in 'L'. Add a 'declare' modifier or an initializer to avoid this. m2() { this.a } diff --git a/tests/baselines/reference/protectedMembers.errors.txt b/tests/baselines/reference/protectedMembers.errors.txt index da2be41e9488e..563a4a757fc6c 100644 --- a/tests/baselines/reference/protectedMembers.errors.txt +++ b/tests/baselines/reference/protectedMembers.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/protectedMembers.ts(25,5): error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. +tests/cases/compiler/protectedMembers.ts(25,5): error TS2610: Property 'x' will overwrite the base property in 'C2'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/compiler/protectedMembers.ts(40,4): error TS2445: Property 'x' is protected and only accessible within class 'C1' and its subclasses. tests/cases/compiler/protectedMembers.ts(41,4): error TS2445: Property 'f' is protected and only accessible within class 'C1' and its subclasses. tests/cases/compiler/protectedMembers.ts(42,4): error TS2445: Property 'sx' is protected and only accessible within class 'C1' and its subclasses. @@ -13,10 +13,10 @@ tests/cases/compiler/protectedMembers.ts(97,1): error TS2322: Type 'B1' is not a Property 'x' is protected but type 'B1' is not a class derived from 'A1'. tests/cases/compiler/protectedMembers.ts(98,1): error TS2322: Type 'A1' is not assignable to type 'B1'. Property 'x' is protected in type 'A1' but public in type 'B1'. -tests/cases/compiler/protectedMembers.ts(104,5): error TS2610: Class 'A2' defines instance member property 'x', so extended class 'B2' must use 'declare' to make it ambient. +tests/cases/compiler/protectedMembers.ts(104,5): error TS2610: Property 'x' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/compiler/protectedMembers.ts(111,7): error TS2415: Class 'B3' incorrectly extends base class 'A3'. Property 'x' is protected in type 'B3' but public in type 'A3'. -tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Class 'A3' defines instance member property 'x', so extended class 'B3' must use 'declare' to make it ambient. +tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Property 'x' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/compiler/protectedMembers.ts (16 errors) ==== @@ -46,7 +46,7 @@ tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Class 'A3' defin class C3 extends C2 { x: number; ~ -!!! error TS2610: Class 'C2' defines instance member property 'x', so extended class 'C3' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'C2'. Add a 'declare' modifier or an initializer to avoid this. static sx: number; f() { return super.f(); @@ -153,7 +153,7 @@ tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Class 'A3' defin class B2 extends A2 { x; ~ -!!! error TS2610: Class 'A2' defines instance member property 'x', so extended class 'B2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. } class A3 { @@ -166,7 +166,7 @@ tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Class 'A3' defin !!! error TS2415: Property 'x' is protected in type 'B3' but public in type 'A3'. protected x; ~ -!!! error TS2610: Class 'A3' defines instance member property 'x', so extended class 'B3' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file diff --git a/tests/baselines/reference/scopeTests.errors.txt b/tests/baselines/reference/scopeTests.errors.txt index cfafac1e1cada..362da88655557 100644 --- a/tests/baselines/reference/scopeTests.errors.txt +++ b/tests/baselines/reference/scopeTests.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/scopeTests.ts(2,7): error TS2415: Class 'D' incorrectly extends base class 'C'. Property 'v' is private in type 'C' but not in type 'D'. -tests/cases/compiler/scopeTests.ts(4,10): error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must use 'declare' to make it ambient. +tests/cases/compiler/scopeTests.ts(4,10): error TS2610: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/compiler/scopeTests.ts (2 errors) ==== @@ -12,7 +12,7 @@ tests/cases/compiler/scopeTests.ts(4,10): error TS2610: Class 'C' defines instan public v: number; public p: number ~ -!!! error TS2610: Class 'C' defines instance member property 'p', so extended class 'D' must use 'declare' to make it ambient. +!!! error TS2610: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. constructor() { super() this.v = 1; diff --git a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt index 44c8e7ba6a51d..33f7c1d48ec2d 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt @@ -1,7 +1,7 @@ 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 'C3'. Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(8,5): error TS2610: Class 'C3' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(8,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (2 errors) ==== @@ -18,7 +18,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ~~~ -!!! error TS2610: Class 'C3' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } function f1(x: T, y: U) { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index d1b6e7efe3aef..d951b47e4cff9 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt @@ -1,33 +1,33 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(37,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(42,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(37,5): error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(42,5): error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. 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(47,5): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'B1'. Type 'V' is not assignable to type 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(52,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(52,5): error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. 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(57,5): error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'B1'. Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. Type 'Foo' is not assignable to type 'T'. 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. 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(62,5): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'B1'. Type 'V' is not assignable to type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. 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(67,5): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'B1'. Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. Type 'Foo' is not assignable to type 'U'. 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(72,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(72,5): error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. 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'. 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 'B1'. Type 'V' is not assignable to type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (19 errors) ==== @@ -69,14 +69,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: Foo; foo: T; // ok ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } class D2 extends B1 { [x: string]: Foo; foo: U; // ok ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } class D3 extends B1 { @@ -88,14 +88,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'V' is not assignable to type 'Foo'. ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } class D4 extends B1 { [x: string]: T; foo: T; // ok ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } class D5 extends B1 { @@ -110,7 +110,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'Foo' is not assignable to type 'T'. !!! error TS2416: 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } class D6 extends B1 { @@ -122,7 +122,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'V' is not assignable to type 'T'. ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } class D7 extends B1 { @@ -137,14 +137,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'Foo' is not assignable to type 'U'. !!! error TS2416: 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } class D8 extends B1 { [x: string]: U; foo: U; // ok ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } class D9 extends B1 { @@ -156,5 +156,5 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D9' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'V' is not assignable to type 'U'. ~~~ -!!! error TS2610: Class 'B1' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt index 5ef5c6aa184ed..f1c67351d3370 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt @@ -1,81 +1,81 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(63,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(63,9): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. 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(68,9): error TS2416: Property 'foo' in type 'D2' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(68,9): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. 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(73,9): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(73,9): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. 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(78,9): error TS2416: Property 'foo' in type 'D4' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(83,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(78,9): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(83,9): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. 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(88,9): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(88,9): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. 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(93,9): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(93,9): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. 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(98,9): error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'Base'. 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 TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(103,9): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(98,9): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(103,9): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. 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 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(115,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. 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(120,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(120,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. 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(125,9): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(125,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. 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(130,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(130,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. 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 'Base2'. 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(135,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(135,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. 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(140,9): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(140,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. 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(145,9): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(145,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. 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'. 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 'Base2'. 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 TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(155,9): error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(150,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(155,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (42 errors) ==== @@ -143,7 +143,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: T ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D2, U extends Foo, V extends Foo> extends Base { @@ -156,7 +156,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D3, U extends Foo, V extends Foo> extends Base { @@ -169,7 +169,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'V' is not assignable to type 'T'. !!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D4, U extends Foo, V extends Foo> extends Base { @@ -182,14 +182,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'T' is not assignable to type 'U'. !!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D5, U extends Foo, V extends Foo> extends Base { [x: string]: U; foo: U ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D6, U extends Foo, V extends Foo> extends Base { @@ -202,7 +202,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'V' is not assignable to type 'U'. !!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D7, U extends Foo, V extends Foo> extends Base { @@ -215,7 +215,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'T' is not assignable to type 'V'. !!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D8, U extends Foo, V extends Foo> extends Base { @@ -228,14 +228,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'U' is not assignable to type 'V'. !!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D9, U extends Foo, V extends Foo> extends Base { [x: string]: V; foo: V ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } } @@ -255,7 +255,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. } class D2, U extends Foo, V extends Foo> extends Base2 { @@ -264,7 +264,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. } class D3, U extends Foo, V extends Foo> extends Base2 { @@ -279,7 +279,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'V' is not assignable to type 'T'. !!! error TS2416: Type 'Foo' is not assignable to type 'T'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. } class D4, U extends Foo, V extends Foo> extends Base2 { @@ -288,7 +288,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf ~~~ !!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. } class D5, U extends Foo, V extends Foo> extends Base2 { @@ -301,7 +301,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'T' is not assignable to type 'U'. !!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. } class D6, U extends Foo, V extends Foo> extends Base2 { @@ -316,7 +316,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'V' is not assignable to type 'U'. !!! error TS2416: Type 'Foo' is not assignable to type 'U'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. } class D7, U extends Foo, V extends Foo> extends Base2 { @@ -331,7 +331,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'U' is not assignable to type 'V'. !!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. } class D8, U extends Foo, V extends Foo> extends Base2 { @@ -346,13 +346,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'T' is not assignable to type 'V'. !!! error TS2416: Type 'Foo' is not assignable to type 'V'. ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. } class D9, U extends Foo, V extends Foo> extends Base2 { [x: string]: V; foo: V ~~~ -!!! error TS2610: Class 'Base2' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this. } } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingTransitivity.errors.txt b/tests/baselines/reference/subtypingTransitivity.errors.txt index c2ca02697cdd4..aed2b0a7220b7 100644 --- a/tests/baselines/reference/subtypingTransitivity.errors.txt +++ b/tests/baselines/reference/subtypingTransitivity.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/subtypingTransitivity.ts(6,12): error TS2610: Class 'B' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. -tests/cases/compiler/subtypingTransitivity.ts(9,12): error TS2610: Class 'B' defines instance member property 'x', so extended class 'D2' must use 'declare' to make it ambient. +tests/cases/compiler/subtypingTransitivity.ts(6,12): error TS2610: Property 'x' will overwrite the base property in 'B'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/compiler/subtypingTransitivity.ts(9,12): error TS2610: Property 'x' will overwrite the base property in 'B'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/compiler/subtypingTransitivity.ts (2 errors) ==== @@ -10,12 +10,12 @@ tests/cases/compiler/subtypingTransitivity.ts(9,12): error TS2610: Class 'B' def class D extends B { public x: string; ~ -!!! error TS2610: Class 'B' defines instance member property 'x', so extended class 'D' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'B'. Add a 'declare' modifier or an initializer to avoid this. } class D2 extends B { public x: number; ~ -!!! error TS2610: Class 'B' defines instance member property 'x', so extended class 'D2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'x' will overwrite the base property in 'B'. Add a 'declare' modifier or an initializer to avoid this. } var b: B; diff --git a/tests/baselines/reference/subtypingWithObjectMembers.errors.txt b/tests/baselines/reference/subtypingWithObjectMembers.errors.txt index b748602a82bf1..140fef4236192 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers.errors.txt +++ b/tests/baselines/reference/subtypingWithObjectMembers.errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(13,5): error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(13,5): error TS2610: Property 'foo' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. 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 'A'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(14,5): error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(23,5): error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(14,5): error TS2610: Property 'bar' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(23,5): error TS2610: Property '1' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. 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 'A2'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(24,5): error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(33,5): error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(24,5): error TS2610: Property '2.0' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(33,5): error TS2610: Property ''1'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. 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 'A3'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(34,5): error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(44,9): error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(34,5): error TS2610: Property ''2.0'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(44,9): error TS2610: Property 'foo' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. 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 'A'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(45,9): error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(54,9): error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(45,9): error TS2610: Property 'bar' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(54,9): error TS2610: Property '1' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. 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 'A2'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(55,9): error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(64,9): error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(55,9): error TS2610: Property '2.0' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(64,9): error TS2610: Property ''1'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. 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 'A3'. Type 'string' is not assignable to type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(65,9): error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(65,9): error TS2610: Property ''2.0'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts (18 errors) ==== @@ -39,13 +39,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { foo: Derived; // ok ~~~ -!!! error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. bar: string; // error ~~~ !!! error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'A'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~~~ -!!! error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must use 'declare' to make it ambient. +!!! error TS2610: Property 'bar' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. } class A2 { @@ -56,13 +56,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B2 extends A2 { 1: Derived; // ok ~ -!!! error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must use 'declare' to make it ambient. +!!! error TS2610: Property '1' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. 2: string; // error ~ !!! error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'A2'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~ -!!! error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must use 'declare' to make it ambient. +!!! error TS2610: Property '2.0' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. } class A3 { @@ -73,13 +73,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A3 { '1': Derived; // ok ~~~ -!!! error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must use 'declare' to make it ambient. +!!! error TS2610: Property ''1'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. '2.0': string; // error ~~~~~ !!! error TS2416: Property ''2.0'' in type 'B3' is not assignable to the same property in base type 'A3'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~~~~~ -!!! error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must use 'declare' to make it ambient. +!!! error TS2610: Property ''2.0'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. } module TwoLevels { @@ -91,13 +91,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { foo: Derived2; // ok ~~~ -!!! error TS2610: Class 'A' defines instance member property 'foo', so extended class 'B' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. bar: string; // error ~~~ !!! error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'A'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~~~ -!!! error TS2610: Class 'A' defines instance member property 'bar', so extended class 'B' must use 'declare' to make it ambient. +!!! error TS2610: Property 'bar' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. } class A2 { @@ -108,13 +108,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B2 extends A2 { 1: Derived2; // ok ~ -!!! error TS2610: Class 'A2' defines instance member property '1', so extended class 'B2' must use 'declare' to make it ambient. +!!! error TS2610: Property '1' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. 2: string; // error ~ !!! error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'A2'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~ -!!! error TS2610: Class 'A2' defines instance member property '2.0', so extended class 'B2' must use 'declare' to make it ambient. +!!! error TS2610: Property '2.0' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. } class A3 { @@ -125,12 +125,12 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A3 { '1': Derived2; // ok ~~~ -!!! error TS2610: Class 'A3' defines instance member property ''1'', so extended class 'B3' must use 'declare' to make it ambient. +!!! error TS2610: Property ''1'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. '2.0': string; // error ~~~~~ !!! error TS2416: Property ''2.0'' in type 'B3' is not assignable to the same property in base type 'A3'. !!! error TS2416: Type 'string' is not assignable to type 'Base'. ~~~~~ -!!! error TS2610: Class 'A3' defines instance member property ''2.0'', so extended class 'B3' must use 'declare' to make it ambient. +!!! error TS2610: Property ''2.0'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. } } \ No newline at end of file diff --git a/tests/baselines/reference/tsxGenericAttributesType5.errors.txt b/tests/baselines/reference/tsxGenericAttributesType5.errors.txt index 5143478df0c47..602526de4dfcc 100644 --- a/tests/baselines/reference/tsxGenericAttributesType5.errors.txt +++ b/tests/baselines/reference/tsxGenericAttributesType5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must use 'declare' to make it ambient. +tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Property 'props' will overwrite the base property in 'Component'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component class B extends React.Component { props: U; ~~~~~ -!!! error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must use 'declare' to make it ambient. +!!! error TS2610: Property 'props' will overwrite the base property in 'Component'. Add a 'declare' modifier or an initializer to avoid this. render() { return ; } diff --git a/tests/baselines/reference/tsxGenericAttributesType6.errors.txt b/tests/baselines/reference/tsxGenericAttributesType6.errors.txt index e1933e9a5c670..a75ae10b22a2d 100644 --- a/tests/baselines/reference/tsxGenericAttributesType6.errors.txt +++ b/tests/baselines/reference/tsxGenericAttributesType6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must use 'declare' to make it ambient. +tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Property 'props' will overwrite the base property in 'Component'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Class 'Component class B extends React.Component { props: U; ~~~~~ -!!! error TS2610: Class 'Component' defines instance member property 'props', so extended class 'B' must use 'declare' to make it ambient. +!!! error TS2610: Property 'props' will overwrite the base property in 'Component'. Add a 'declare' modifier or an initializer to avoid this. render() { return ; } diff --git a/tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt b/tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt index eb283445e2327..021d240b8a533 100644 --- a/tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt +++ b/tests/baselines/reference/undefinedIsSubtypeOfEverything.errors.txt @@ -1,25 +1,25 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(8,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D0' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(12,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'DA' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(16,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(20,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1A' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(25,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(29,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2A' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(34,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(38,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3A' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(43,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(47,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(52,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(56,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(61,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(68,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(73,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D10' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(78,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D11' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(86,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D12' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(95,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D13' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(100,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D14' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(105,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D15' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(114,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D16' must use 'declare' to make it ambient. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(119,5): error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D17' must use 'declare' to make it ambient. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(8,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(12,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(16,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(20,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(25,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(29,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(34,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(38,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(43,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(47,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(52,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(56,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(61,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(68,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(73,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(78,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(86,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(95,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(100,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(105,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(114,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(119,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts (22 errors) ==== @@ -32,84 +32,84 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedI class D0 extends Base { foo: any; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D0' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class DA extends Base { foo: typeof undefined; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'DA' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D1 extends Base { foo: string; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D1A extends Base { foo: String; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D1A' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D2 extends Base { foo: number; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D2A extends Base { foo: Number; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D2A' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D3 extends Base { foo: boolean; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D3A extends Base { foo: Boolean; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D3A' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D4 extends Base { foo: RegExp; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D4' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D5 extends Base { foo: Date; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D5' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D6 extends Base { foo: number[]; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D6' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D7 extends Base { foo: { bar: number }; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D7' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D8 extends Base { foo: D7; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D8' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } interface I1 { @@ -118,21 +118,21 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedI class D9 extends Base { foo: I1; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D9' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D10 extends Base { foo: () => number; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D10' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } enum E { A } class D11 extends Base { foo: E; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D11' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } function f() { } @@ -142,7 +142,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedI class D12 extends Base { foo: typeof f; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D12' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } @@ -153,21 +153,21 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedI class D13 extends Base { foo: typeof c; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D13' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D14 extends Base { foo: T; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D14' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D15 extends Base { foo: U; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D15' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } //class D15 extends Base { @@ -178,13 +178,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedI class D16 extends Base { foo: Object; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D16' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } class D17 extends Base { foo: {}; ~~~ -!!! error TS2610: Class 'Base' defines instance member property 'foo', so extended class 'D17' must use 'declare' to make it ambient. +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file From f11f2beb5e287b891022335030a36da3ab0ac49a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 17 Sep 2019 09:21:15 -0700 Subject: [PATCH 07/17] Add codefix to add missing 'declare' --- src/compiler/diagnosticMessages.json | 8 +++++ .../codefixes/addMissingDeclareProperty.ts | 34 +++++++++++++++++++ src/services/tsconfig.json | 1 + .../codeFixAddMissingDeclareProperty.ts | 18 ++++++++++ .../codeFixAddMissingDeclareProperty2.ts | 25 ++++++++++++++ 5 files changed, 86 insertions(+) create mode 100644 src/services/codefixes/addMissingDeclareProperty.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index baa77494e818b..b8cbb418b1d52 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -5148,6 +5148,14 @@ "category": "Message", "code": 95092 }, + "Prefix with 'declare'": { + "category": "Message", + "code": 95093 + }, + "Prefix all incorrect property declarations with 'declare'": { + "category": "Message", + "code": 95094 + }, "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": { "category": "Error", diff --git a/src/services/codefixes/addMissingDeclareProperty.ts b/src/services/codefixes/addMissingDeclareProperty.ts new file mode 100644 index 0000000000000..002357239ead2 --- /dev/null +++ b/src/services/codefixes/addMissingDeclareProperty.ts @@ -0,0 +1,34 @@ +/* @internal */ +namespace ts.codefix { + const fixId = "addMissingDeclareProperty"; + const errorCodes = [ + Diagnostics.Property_0_will_overwrite_the_base_property_in_1_Add_a_declare_modifier_or_an_initializer_to_avoid_this.code, + ]; + + registerCodeFix({ + errorCodes, + getCodeActions: (context) => { + const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start)); + if (changes.length > 0) { + return [createCodeFixAction(fixId, changes, Diagnostics.Prefix_with_declare, fixId, Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)]; + } + }, + fixIds: [fixId], + getAllCodeActions: context => { + const fixedNodes = new NodeSet(); + return codeFixAll(context, errorCodes, (changes, diag) => makeChange(changes, diag.file, diag.start, fixedNodes)); + }, + }); + + function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number, fixedNodes?: NodeSet) { + const token = getTokenAtPosition(sourceFile, pos); + if (!isIdentifier(token)) { + return; + } + const declaration = token.parent; + if (declaration.kind === SyntaxKind.PropertyDeclaration && + (!fixedNodes || fixedNodes.tryAdd(declaration))) { + changeTracker.insertModifierBefore(sourceFile, SyntaxKind.DeclareKeyword, declaration); + } + } +} diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 74495bc54f88b..32472fb776f44 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -47,6 +47,7 @@ "codefixes/addConvertToUnknownForNonOverlappingTypes.ts", "codefixes/addMissingAwait.ts", "codefixes/addMissingConst.ts", + "codefixes/addMissingDeclareProperty.ts", "codefixes/addMissingInvocationForDecorator.ts", "codefixes/addNameToNamelessParameter.ts", "codefixes/annotateWithTypeFromJSDoc.ts", diff --git a/tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts b/tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts new file mode 100644 index 0000000000000..90dcbdd86ba8d --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts @@ -0,0 +1,18 @@ +/// + +////class B { +//// p = 1 +////} +////class C extends B { +//// p: number +////} + +verify.codeFix({ + description: "Prefix with 'declare'", + newFileContent: `class B { + p = 1 +} +class C extends B { + declare p: number +}` +}); diff --git a/tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts b/tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts new file mode 100644 index 0000000000000..32dc21d9a2753 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts @@ -0,0 +1,25 @@ +/// + +////class B { +//// p = 1 +////} +////class C extends B { +//// p: number +////} +////class D extends B { +//// p: 1 | 2 | 3 +////} + +verify.codeFixAll({ + fixId: "addMissingDeclareProperty", + fixAllDescription: "Prefix all incorrect property declarations with 'declare'", + newFileContent: `class B { + p = 1 +} +class C extends B { + declare p: number +} +class D extends B { + declare p: 1 | 2 | 3 +}` +}); From fcf0ff1dfde03a31100102af2adc8a512819e66c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 17 Sep 2019 11:24:47 -0700 Subject: [PATCH 08/17] Allow 'declare' on any uninitialised property decl --- src/compiler/checker.ts | 15 --------------- src/compiler/diagnosticMessages.json | 4 ---- .../classExpressionPropertyModifiers.errors.txt | 5 +---- ...vedUninitializedPropertyDeclaration.errors.txt | 12 +++--------- .../derivedUninitializedPropertyDeclaration.js | 4 ++-- ...erivedUninitializedPropertyDeclaration.symbols | 4 ++-- .../derivedUninitializedPropertyDeclaration.types | 4 ++-- .../illegalModifiersOnClassElements.errors.txt | 5 +---- .../parserMemberAccessorDeclaration11.errors.txt | 5 +---- .../parserMemberFunctionDeclaration5.errors.txt | 5 +---- .../parserMemberVariableDeclaration5.errors.txt | 9 --------- .../derivedUninitializedPropertyDeclaration.ts | 4 ++-- 12 files changed, 15 insertions(+), 61 deletions(-) delete mode 100644 tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0b1e43dc205ba..6340bb3b27ad7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29358,7 +29358,6 @@ namespace ts { checkKindsOfPropertyMemberOverrides(type, baseType); } } - checkAmbientPropertyMemberOverrides(type, baseType); const implementedTypeNodes = getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { @@ -29562,20 +29561,6 @@ namespace ts { } } - function checkAmbientPropertyMemberOverrides(type: Type, baseType?: Type) { - for (const derivedProperty of getPropertiesOfType(type)) { - const derived = getTargetSymbol(derivedProperty); - if (derived.flags & SymbolFlags.Prototype) { - continue; - } - const base = baseType && getPropertyOfObjectType(baseType, derived.escapedName); - if (!base && getDeclarationModifierFlagsFromSymbol(derived) & ModifierFlags.Ambient) { - const errorMessage = Diagnostics.Ambient_property_declarations_must_override_a_property_in_a_base_class; - error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage); - } - } - } - function checkInheritedPropertiesAreIdentical(type: InterfaceType, typeNode: Node): boolean { const baseTypes = getBaseTypes(type); if (baseTypes.length < 2) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e6c5ca99ab16e..957e1911ec3fa 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2208,10 +2208,6 @@ "category": "Error", "code": 2610 }, - "Ambient property declarations must override a property in a base class.": { - "category": "Error", - "code": 2611 - }, "Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": { "category": "Error", "code": 2649 diff --git a/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt b/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt index 94f55b688b19b..cb01d6561260f 100644 --- a/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt +++ b/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt @@ -1,13 +1,10 @@ -tests/cases/compiler/classExpressionPropertyModifiers.ts(2,13): error TS2611: Ambient property declarations must override a property in a base class. tests/cases/compiler/classExpressionPropertyModifiers.ts(2,36): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/classExpressionPropertyModifiers.ts(3,5): error TS1031: 'export' modifier cannot appear on a class element. -==== tests/cases/compiler/classExpressionPropertyModifiers.ts (3 errors) ==== +==== tests/cases/compiler/classExpressionPropertyModifiers.ts (2 errors) ==== const a = class Cat { declare [Symbol.toStringTag] = "uh"; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2611: Ambient property declarations must override a property in a base class. ~~~~ !!! error TS1039: Initializers are not allowed in ambient contexts. export foo = 1; diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt index 737c83bd0ce8c..ee271d7fb7f76 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -1,15 +1,13 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(6,5): error TS2610: Property 'property' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,5): error TS1031: 'declare' modifier cannot appear on a class element. -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(16,13): error TS2611: Ambient property declarations must override a property in a base class. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(17,24): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(20,13): error TS2611: Ambient property declarations must override a property in a base class. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(24,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2610: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(39,5): error TS2610: Property 'p1' will overwrite the base property in 'E'. Add a 'declare' modifier or an initializer to avoid this. -==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (9 errors) ==== +==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (7 errors) ==== class A { property = 'x'; m() { return 1 } @@ -29,17 +27,13 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP declare m() { return 2 } // not allowed on methods ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. - declare nonce: any; // only allowed when exists in base - ~~~~~ -!!! error TS2611: Ambient property declarations must override a property in a base class. + declare nonce: any; // ok, even though it's not in the base declare property = 'y' // initialiser not allowed with declare ~~~ !!! error TS1039: Initializers are not allowed in ambient contexts. } class U { - declare nonce: any; // ambient declaration only allowed when an override - ~~~~~ -!!! error TS2611: Ambient property declarations must override a property in a base class. + declare nonce: any; // ok, even though there's no base } class C { diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js index a07c27531cfd5..ca2d410a8e9eb 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js @@ -14,11 +14,11 @@ class BDBang extends A { } class BOther extends A { declare m() { return 2 } // not allowed on methods - declare nonce: any; // only allowed when exists in base + declare nonce: any; // ok, even though it's not in the base declare property = 'y' // initialiser not allowed with declare } class U { - declare nonce: any; // ambient declaration only allowed when an override + declare nonce: any; // ok, even though there's no base } class C { diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols index 298022d3c2fd1..4375b9010cf4b 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols @@ -36,7 +36,7 @@ class BOther extends A { declare m() { return 2 } // not allowed on methods >m : Symbol(BOther.m, Decl(derivedUninitializedPropertyDeclaration.ts, 13, 24)) - declare nonce: any; // only allowed when exists in base + declare nonce: any; // ok, even though it's not in the base >nonce : Symbol(BOther.nonce, Decl(derivedUninitializedPropertyDeclaration.ts, 14, 28)) declare property = 'y' // initialiser not allowed with declare @@ -45,7 +45,7 @@ class BOther extends A { class U { >U : Symbol(U, Decl(derivedUninitializedPropertyDeclaration.ts, 17, 1)) - declare nonce: any; // ambient declaration only allowed when an override + declare nonce: any; // ok, even though there's no base >nonce : Symbol(U.nonce, Decl(derivedUninitializedPropertyDeclaration.ts, 18, 9)) } diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types index 44d839492b5eb..cc82567babba3 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types @@ -39,7 +39,7 @@ class BOther extends A { >m : () => number >2 : 2 - declare nonce: any; // only allowed when exists in base + declare nonce: any; // ok, even though it's not in the base >nonce : any declare property = 'y' // initialiser not allowed with declare @@ -49,7 +49,7 @@ class BOther extends A { class U { >U : U - declare nonce: any; // ambient declaration only allowed when an override + declare nonce: any; // ok, even though there's no base >nonce : any } diff --git a/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt b/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt index d8e6e10158f54..99ba043b52a80 100644 --- a/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt +++ b/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt @@ -1,13 +1,10 @@ -tests/cases/compiler/illegalModifiersOnClassElements.ts(2,13): error TS2611: Ambient property declarations must override a property in a base class. tests/cases/compiler/illegalModifiersOnClassElements.ts(2,19): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/illegalModifiersOnClassElements.ts(3,5): error TS1031: 'export' modifier cannot appear on a class element. -==== tests/cases/compiler/illegalModifiersOnClassElements.ts (3 errors) ==== +==== tests/cases/compiler/illegalModifiersOnClassElements.ts (2 errors) ==== class C { declare foo = 1; - ~~~ -!!! error TS2611: Ambient property declarations must override a property in a base class. ~ !!! error TS1039: Initializers are not allowed in ambient contexts. export bar = 1; diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration11.errors.txt b/tests/baselines/reference/parserMemberAccessorDeclaration11.errors.txt index 47a9e27f73e2d..3a04bfbbd0296 100644 --- a/tests/baselines/reference/parserMemberAccessorDeclaration11.errors.txt +++ b/tests/baselines/reference/parserMemberAccessorDeclaration11.errors.txt @@ -1,15 +1,12 @@ tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts(2,17): error TS2378: A 'get' accessor must return a value. -tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts(2,17): error TS2611: Ambient property declarations must override a property in a base class. -==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts (2 errors) ==== class C { declare get Foo() { } ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. ~~~ !!! error TS2378: A 'get' accessor must return a value. - ~~~ -!!! error TS2611: Ambient property declarations must override a property in a base class. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt index 25544ddeda5c4..dc19cb0f8550a 100644 --- a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt +++ b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt @@ -1,12 +1,9 @@ tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. -tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,13): error TS2611: Ambient property declarations must override a property in a base class. -==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (1 errors) ==== class C { declare Foo() { } ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. - ~~~ -!!! error TS2611: Ambient property declarations must override a property in a base class. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt b/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt deleted file mode 100644 index 9ad6081cdf6d9..0000000000000 --- a/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration5.ts(2,11): error TS2611: Ambient property declarations must override a property in a base class. - - -==== tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration5.ts (1 errors) ==== - class C { - declare Foo; - ~~~ -!!! error TS2611: Ambient property declarations must override a property in a base class. - } \ No newline at end of file diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts index fa4fd86f01e85..a28beddd0205e 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts @@ -14,11 +14,11 @@ class BDBang extends A { } class BOther extends A { declare m() { return 2 } // not allowed on methods - declare nonce: any; // only allowed when exists in base + declare nonce: any; // ok, even though it's not in the base declare property = 'y' // initialiser not allowed with declare } class U { - declare nonce: any; // ambient declaration only allowed when an override + declare nonce: any; // ok, even though there's no base } class C { From 810f923d54445346fbc28cadf46271372c204c11 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 17 Sep 2019 11:27:21 -0700 Subject: [PATCH 09/17] Undo code moves --- src/compiler/checker.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6340bb3b27ad7..0d57f278e8eb5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29206,11 +29206,6 @@ namespace ts { } } - function getClassOrInterfaceDeclarationsOfSymbol(symbol: Symbol) { - return filter(symbol.declarations, (d: Declaration): d is ClassDeclaration | InterfaceDeclaration => - d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.InterfaceDeclaration); - } - function areTypeParametersIdentical(declarations: readonly (ClassDeclaration | InterfaceDeclaration)[], targetParameters: TypeParameter[]) { const maxTypeArgumentCount = length(targetParameters); const minTypeArgumentCount = getMinTypeArgumentCount(targetParameters); @@ -29304,7 +29299,6 @@ namespace ts { checkClassForStaticPropertyNameConflicts(node); } - let baseType: BaseType | undefined; const baseTypeNode = getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < ScriptTarget.ES2015) { @@ -29318,7 +29312,7 @@ namespace ts { const baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { - baseType = baseTypes[0]; + const baseType = baseTypes[0]; const baseConstructorType = getBaseConstructorTypeOfClass(type); const staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); @@ -29443,6 +29437,11 @@ namespace ts { return getCheckFlags(s) & CheckFlags.Instantiated ? (s).target! : s; } + function getClassOrInterfaceDeclarationsOfSymbol(symbol: Symbol) { + return filter(symbol.declarations, (d: Declaration): d is ClassDeclaration | InterfaceDeclaration => + d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.InterfaceDeclaration); + } + /** * TypeScript 1.0 spec (April 2014): 8.2.3 * A derived class inherits all members from its base class it doesn't override. From 6408d7abe6bc39e703ab568e40063c75b83bceee Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 17 Sep 2019 11:29:54 -0700 Subject: [PATCH 10/17] Let sleeping dogs lie --- src/compiler/checker.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0d57f278e8eb5..6c9e06fb33e2a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29442,22 +29442,21 @@ namespace ts { d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.InterfaceDeclaration); } - /** - * TypeScript 1.0 spec (April 2014): 8.2.3 - * A derived class inherits all members from its base class it doesn't override. - * Inheritance means that a derived class implicitly contains all non - overridden members of the base class. - * Both public and private property members are inherited, but only public property members can be overridden. - * A property member in a derived class is said to override a property member in a base class - * when the derived class property member has the same name and kind(instance or static) - * as the base class property member. - * The type of an overriding property member must be assignable(section 3.8.4) - * to the type of the overridden property member, or otherwise a compile - time error occurs. - * Base class instance member functions can be overridden by derived class instance member functions, - * but not by other kinds of members. - * Base class instance member variables and accessors can be overridden by - * derived class instance member variables and accessors, but not by other kinds of members. - */ function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: BaseType): void { + // TypeScript 1.0 spec (April 2014): 8.2.3 + // A derived class inherits all members from its base class it doesn't override. + // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. + // Both public and private property members are inherited, but only public property members can be overridden. + // A property member in a derived class is said to override a property member in a base class + // when the derived class property member has the same name and kind(instance or static) + // as the base class property member. + // The type of an overriding property member must be assignable(section 3.8.4) + // to the type of the overridden property member, or otherwise a compile - time error occurs. + // Base class instance member functions can be overridden by derived class instance member functions, + // but not by other kinds of members. + // Base class instance member variables and accessors can be overridden by + // derived class instance member variables and accessors, but not by other kinds of members. + // NOTE: assignability is checked in checkClassDeclaration const baseProperties = getPropertiesOfType(baseType); basePropertyCheck: for (const baseProperty of baseProperties) { From 5ee327185c07853791361d2fe692798930461c8e Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 17 Sep 2019 13:45:51 -0700 Subject: [PATCH 11/17] Correctly set NodeFlags.Ambient And simplify redundant parts of check. --- src/compiler/checker.ts | 3 +-- src/compiler/parser.ts | 12 ++++++++++-- ...erivedUninitializedPropertyDeclaration.errors.txt | 10 ++++++++-- .../derivedUninitializedPropertyDeclaration.js | 2 +- .../derivedUninitializedPropertyDeclaration.symbols | 2 +- .../derivedUninitializedPropertyDeclaration.types | 2 +- .../parserMemberFunctionDeclaration5.errors.txt | 5 ++++- .../derivedUninitializedPropertyDeclaration.ts | 2 +- 8 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6c9e06fb33e2a..2012a98534fd1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29519,10 +29519,9 @@ namespace ts { if (base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) { const uninitialized = find(derived.declarations, d => d.kind === SyntaxKind.PropertyDeclaration && !(d as PropertyDeclaration).initializer); if (uninitialized - && derived.flags & SymbolFlags.Property && !(derived.flags & SymbolFlags.Transient) && !(baseDeclarationFlags & ModifierFlags.Abstract) - && !(derivedDeclarationFlags & (ModifierFlags.Ambient | ModifierFlags.Abstract)) + && !(derivedDeclarationFlags & ModifierFlags.Abstract) && !derived.declarations.some(d => d.flags & NodeFlags.Ambient)) { const constructor = findConstructorDeclaration(getClassLikeDeclarationOfSymbol(type.symbol)!); const propName = (uninitialized as PropertyDeclaration).name; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f437ca697a854..669c41094a697 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5982,8 +5982,16 @@ namespace ts { token() === SyntaxKind.NumericLiteral || token() === SyntaxKind.AsteriskToken || token() === SyntaxKind.OpenBracketToken) { - - return parsePropertyOrMethodDeclaration(node); + const isAmbient = node.modifiers && some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (const m of node.modifiers!) { + m.flags |= NodeFlags.Ambient; + } + return doInsideOfContext(NodeFlags.Ambient, () => parsePropertyOrMethodDeclaration(node as PropertyDeclaration | MethodDeclaration)); + } + else { + return parsePropertyOrMethodDeclaration(node as PropertyDeclaration | MethodDeclaration); + } } if (node.decorators || node.modifiers) { diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt index ee271d7fb7f76..62c7aedfbbea7 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -1,5 +1,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(6,5): error TS2610: Property 'property' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(12,21): error TS1255: A definite assignment assertion '!' is not permitted in this context. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,5): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,17): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(17,24): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(24,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. @@ -7,7 +9,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(39,5): error TS2610: Property 'p1' will overwrite the base property in 'E'. Add a 'declare' modifier or an initializer to avoid this. -==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (7 errors) ==== +==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (9 errors) ==== class A { property = 'x'; m() { return 1 } @@ -21,12 +23,16 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP declare property: any; // ok because it's implicitly initialised } class BDBang extends A { - declare property!: any; // doesn't need !, but is still allowed + declare property!: any; // ! is not allowed, this is an ambient declaration + ~ +!!! error TS1255: A definite assignment assertion '!' is not permitted in this context. } class BOther extends A { declare m() { return 2 } // not allowed on methods ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. declare nonce: any; // ok, even though it's not in the base declare property = 'y' // initialiser not allowed with declare ~~~ diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js index ca2d410a8e9eb..decc56a4867c2 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js @@ -10,7 +10,7 @@ class BD extends A { declare property: any; // ok because it's implicitly initialised } class BDBang extends A { - declare property!: any; // doesn't need !, but is still allowed + declare property!: any; // ! is not allowed, this is an ambient declaration } class BOther extends A { declare m() { return 2 } // not allowed on methods diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols index 4375b9010cf4b..2ed91c2c2d172 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols @@ -26,7 +26,7 @@ class BDBang extends A { >BDBang : Symbol(BDBang, Decl(derivedUninitializedPropertyDeclaration.ts, 9, 1)) >A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) - declare property!: any; // doesn't need !, but is still allowed + declare property!: any; // ! is not allowed, this is an ambient declaration >property : Symbol(BDBang.property, Decl(derivedUninitializedPropertyDeclaration.ts, 10, 24)) } class BOther extends A { diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types index cc82567babba3..aa4e7ba501e42 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types @@ -28,7 +28,7 @@ class BDBang extends A { >BDBang : BDBang >A : A - declare property!: any; // doesn't need !, but is still allowed + declare property!: any; // ! is not allowed, this is an ambient declaration >property : any } class BOther extends A { diff --git a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt index dc19cb0f8550a..402355919a031 100644 --- a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt +++ b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,19): error TS1183: An implementation cannot be declared in ambient contexts. -==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (2 errors) ==== class C { declare Foo() { } ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. + ~ +!!! error TS1183: An implementation cannot be declared in ambient contexts. } \ No newline at end of file diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts index a28beddd0205e..a3f126c10aec8 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts @@ -10,7 +10,7 @@ class BD extends A { declare property: any; // ok because it's implicitly initialised } class BDBang extends A { - declare property!: any; // doesn't need !, but is still allowed + declare property!: any; // ! is not allowed, this is an ambient declaration } class BOther extends A { declare m() { return 2 } // not allowed on methods From e0ddced06c4c68ab881e58c76cafd4f027b7ed7c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 17 Sep 2019 14:03:01 -0700 Subject: [PATCH 12/17] Remove more unneeded code --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2012a98534fd1..308ddaac6427f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -33637,7 +33637,7 @@ namespace ts { } } - if (node.flags & NodeFlags.Ambient || getModifierFlags(node) & ModifierFlags.Ambient) { + if (node.flags & NodeFlags.Ambient) { checkAmbientInitializer(node); } From 6a066b9a7edc8cdc89ccbecccb633f7f5fcc2b3a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 17 Sep 2019 15:00:00 -0700 Subject: [PATCH 13/17] Update baselines --- .../reference/commentsInheritance.errors.txt | 159 ++++++++++++++++++ .../reference/parserAstSpans1.errors.txt | 8 +- .../reference/parserRealSource11.errors.txt | 8 +- .../reference/parserharness.errors.txt | 14 +- ...AccessibleWithinNestedSubclass1.errors.txt | 5 +- ...opertyAccessibleWithinSubclass2.errors.txt | 5 +- ...sOfTypeParameterWithConstraints.errors.txt | 89 +++++++++- 7 files changed, 282 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/commentsInheritance.errors.txt diff --git a/tests/baselines/reference/commentsInheritance.errors.txt b/tests/baselines/reference/commentsInheritance.errors.txt new file mode 100644 index 0000000000000..2a9a5eff5dca7 --- /dev/null +++ b/tests/baselines/reference/commentsInheritance.errors.txt @@ -0,0 +1,159 @@ +tests/cases/compiler/commentsInheritance.ts(90,12): error TS2610: Property 'p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/compiler/commentsInheritance.ts(98,12): error TS2610: Property 'nc_p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this. + + +==== tests/cases/compiler/commentsInheritance.ts (2 errors) ==== + /** i1 is interface with properties*/ + interface i1 { + /** i1_p1*/ + i1_p1: number; + /** i1_f1*/ + i1_f1(): void; + /** i1_l1*/ + i1_l1: () => void; + // il_nc_p1 + i1_nc_p1: number; + i1_nc_f1(): void; + i1_nc_l1: () => void; + p1: number; + f1(): void; + l1: () => void; + nc_p1: number; + nc_f1(): void; + nc_l1: () => void; + } + class c1 implements i1 { + public i1_p1: number; + // i1_f1 + public i1_f1() { + } + public i1_l1: () => void; + public i1_nc_p1: number; + public i1_nc_f1() { + } + public i1_nc_l1: () => void; + /** c1_p1*/ + public p1: number; + /** c1_f1*/ + public f1() { + } + /** c1_l1*/ + public l1: () => void; + /** c1_nc_p1*/ + public nc_p1: number; + /** c1_nc_f1*/ + public nc_f1() { + } + /** c1_nc_l1*/ + public nc_l1: () => void; + } + var i1_i: i1; + var c1_i = new c1(); + // assign to interface + i1_i = c1_i; + class c2 { + /** c2 c2_p1*/ + public c2_p1: number; + /** c2 c2_f1*/ + public c2_f1() { + } + /** c2 c2_prop*/ + public get c2_prop() { + return 10; + } + public c2_nc_p1: number; + public c2_nc_f1() { + } + public get c2_nc_prop() { + return 10; + } + /** c2 p1*/ + public p1: number; + /** c2 f1*/ + public f1() { + } + /** c2 prop*/ + public get prop() { + return 10; + } + public nc_p1: number; + public nc_f1() { + } + public get nc_prop() { + return 10; + } + /** c2 constructor*/ + constructor(a: number) { + this.c2_p1 = a; + } + } + class c3 extends c2 { + constructor() { + super(10); + } + /** c3 p1*/ + public p1: number; + ~~ +!!! error TS2610: Property 'p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this. + /** c3 f1*/ + public f1() { + } + /** c3 prop*/ + public get prop() { + return 10; + } + public nc_p1: number; + ~~~~~ +!!! error TS2610: Property 'nc_p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this. + public nc_f1() { + } + public get nc_prop() { + return 10; + } + } + var c2_i = new c2(10); + var c3_i = new c3(); + // assign + c2_i = c3_i; + class c4 extends c2 { + } + var c4_i = new c4(10); + interface i2 { + /** i2_p1*/ + i2_p1: number; + /** i2_f1*/ + i2_f1(): void; + /** i2_l1*/ + i2_l1: () => void; + // i2_nc_p1 + i2_nc_p1: number; + i2_nc_f1(): void; + i2_nc_l1: () => void; + /** i2 p1*/ + p1: number; + /** i2 f1*/ + f1(): void; + /** i2 l1*/ + l1: () => void; + nc_p1: number; + nc_f1(): void; + nc_l1: () => void; + } + interface i3 extends i2 { + /** i3 p1 */ + p1: number; + /** + * i3 f1 + */ + f1(): void; + /** i3 l1*/ + l1: () => void; + nc_p1: number; + nc_f1(): void; + nc_l1: () => void; + } + var i2_i: i2; + var i3_i: i3; + // assign to interface + i2_i = i3_i; + \ No newline at end of file diff --git a/tests/baselines/reference/parserAstSpans1.errors.txt b/tests/baselines/reference/parserAstSpans1.errors.txt index 648929e974e3e..6fa8715a8f6ea 100644 --- a/tests/baselines/reference/parserAstSpans1.errors.txt +++ b/tests/baselines/reference/parserAstSpans1.errors.txt @@ -3,12 +3,14 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(85,16): error TS10 tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(94,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(100,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(114,12): error TS2610: Property 'p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(122,12): error TS2610: Property 'nc_p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(125,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. -==== tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts (8 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts (10 errors) ==== /** i1 is interface with properties*/ interface i1 { /** i1_p1*/ @@ -133,6 +135,8 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2 } /** c3 p1*/ public p1: number; + ~~ +!!! error TS2610: Property 'p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this. /** c3 f1*/ public f1() { } @@ -143,6 +147,8 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2 return 10; } public nc_p1: number; + ~~~~~ +!!! error TS2610: Property 'nc_p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this. public nc_f1() { } public get nc_prop() { diff --git a/tests/baselines/reference/parserRealSource11.errors.txt b/tests/baselines/reference/parserRealSource11.errors.txt index bb0a52e0a9997..fdfb15759460e 100644 --- a/tests/baselines/reference/parserRealSource11.errors.txt +++ b/tests/baselines/reference/parserRealSource11.errors.txt @@ -288,6 +288,8 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1095,29): error tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1098,56): error TS2304: Cannot find name 'FncFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1098,79): error TS2304: Cannot find name 'FncFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1111,33): error TS2304: Cannot find name 'IFileReference'. +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1120,16): error TS2610: Property 'vars' will overwrite the base property in 'FuncDecl'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1121,16): error TS2610: Property 'scopes' will overwrite the base property in 'FuncDecl'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1127,84): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1132,36): error TS2304: Cannot find name 'TypeFlow'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1144,42): error TS2304: Cannot find name 'NodeType'. @@ -511,7 +513,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,30): error tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error TS2304: Cannot find name 'TokenID'. -==== tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts (511 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts (513 errors) ==== // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. @@ -2212,7 +2214,11 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error public leftCurlyCount = 0; public rightCurlyCount = 0; public vars: ASTList; + ~~~~ +!!! error TS2610: Property 'vars' will overwrite the base property in 'FuncDecl'. Add a 'declare' modifier or an initializer to avoid this. public scopes: ASTList; + ~~~~~~ +!!! error TS2610: Property 'scopes' will overwrite the base property in 'FuncDecl'. Add a 'declare' modifier or an initializer to avoid this. // Remember if the script contains Unicode chars, that is needed when generating code for this script object to decide the output file correct encoding. public containsUnicodeChar = false; public containsUnicodeCharInComment = false; diff --git a/tests/baselines/reference/parserharness.errors.txt b/tests/baselines/reference/parserharness.errors.txt index 990fa5816c787..9c00868b16d22 100644 --- a/tests/baselines/reference/parserharness.errors.txt +++ b/tests/baselines/reference/parserharness.errors.txt @@ -12,6 +12,10 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(347,13): e tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(351,17): error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(354,17): error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(354,35): error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'? +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(359,16): error TS2610: Property 'description' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(360,16): error TS2610: Property 'block' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(402,16): error TS2610: Property 'description' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(403,16): error TS2610: Property 'block' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(691,50): error TS2304: Cannot find name 'ITextWriter'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(716,47): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(721,62): error TS2304: Cannot find name 'ITextWriter'. @@ -110,7 +114,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1787,68): tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): error TS2304: Cannot find name 'Diff'. -==== tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts (110 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts (114 errors) ==== // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -498,7 +502,11 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): } export class TestCase extends Runnable { public description: string; + ~~~~~~~~~~~ +!!! error TS2610: Property 'description' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this. public block; + ~~~~~ +!!! error TS2610: Property 'block' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this. constructor(description: string, block: any) { super(description, block); @@ -541,7 +549,11 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): export class Scenario extends Runnable { public description: string; + ~~~~~~~~~~~ +!!! error TS2610: Property 'description' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this. public block; + ~~~~~ +!!! error TS2610: Property 'block' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this. constructor(description: string, block: any) { super(description, block); diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.errors.txt b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.errors.txt index 2d882681d7269..dd395b2a2a4a2 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.errors.txt +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.errors.txt @@ -6,6 +6,7 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(52,19): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'. tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(53,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'. tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(55,20): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses. +tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(63,15): error TS2610: Property 'x' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(73,19): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'. tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(74,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'. tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(75,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'. @@ -21,7 +22,7 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(114,4): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses. -==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts (21 errors) ==== +==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts (22 errors) ==== class Base { protected x: string; method() { @@ -101,6 +102,8 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce class Derived3 extends Derived1 { protected x: string; + ~ +!!! error TS2610: Property 'x' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this. method3() { class D { method3d() { diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.errors.txt b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.errors.txt index 996d62c165212..2d43267ed419e 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.errors.txt +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.errors.txt @@ -6,6 +6,7 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(42,11): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'. tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(43,12): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'. tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(45,12): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses. +tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(51,15): error TS2610: Property 'x' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(59,11): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'. tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(60,12): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'. tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(61,12): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'. @@ -21,7 +22,7 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(94,4): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses. -==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts (21 errors) ==== +==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts (22 errors) ==== class Base { protected x: string; method() { @@ -89,6 +90,8 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce class Derived3 extends Derived1 { protected x: string; + ~ +!!! error TS2610: Property 'x' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this. method3() { var b: Base; var d1: Derived1; diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt index 5fe0186e04a1b..37ae8137c5a2b 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt @@ -1,21 +1,39 @@ +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(9,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(14,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. 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(19,5): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'C3'. Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(19,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(24,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(33,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(38,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(43,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. 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(50,5): error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'C3'. Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. Type 'V' is not assignable to type 'T'. 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(55,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(60,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. 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(67,5): error TS2416: Property 'foo' in type 'D11' is not assignable to the same property in base type 'C3'. Type 'V' is not assignable to type 'T'. 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. 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(72,5): error TS2416: Property 'foo' in type 'D12' is not assignable to the same property in base type 'C3'. Type 'V' is not assignable to type 'U'. 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(72,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(77,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(85,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(90,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(95,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(100,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(107,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. 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(112,5): error TS2416: Property 'foo' in type 'D19' is not assignable to the same property in base type 'C3'. Type 'U' is not assignable to type 'T'. @@ -24,33 +42,44 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. Type 'Date' is not assignable to type 'T'. 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(117,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(122,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(129,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. 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(134,5): error TS2416: Property 'foo' in type 'D23' is not assignable to the same property in base type 'C3'. Type 'V' is not assignable to type 'T'. 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. Type 'Date' is not assignable to type 'T'. 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. 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(139,5): error TS2416: Property 'foo' in type 'D24' is not assignable to the same property in base type 'C3'. Type 'V' is not assignable to type 'U'. 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. Type 'Date' is not assignable to type 'U'. 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(144,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(151,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. 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(156,5): error TS2416: Property 'foo' in type 'D27' is not assignable to the same property in base type 'C3'. Type 'Date' is not assignable to type 'T'. 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. 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(161,5): error TS2416: Property 'foo' in type 'D28' is not assignable to the same property in base type 'C3'. Type 'Date' is not assignable to type 'U'. 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(161,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. 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'. 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 'C3'. Type 'Date' is not assignable to type 'V'. 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(166,5): error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. -==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts (20 errors) ==== +==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts (49 errors) ==== // checking whether other types are subtypes of type parameters with constraints class C3 { @@ -60,11 +89,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf class D1 extends C3 { [x: string]: T; foo: T; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D2 extends C3 { [x: string]: U; foo: T; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D3 extends C3 { @@ -76,11 +109,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D4 extends C3 { [x: string]: U; foo: U; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } @@ -90,16 +127,22 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf class D5 extends C3 { [x: string]: T; foo: T; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D6 extends C3 { [x: string]: U; foo: T; + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D7 extends C3 { [x: string]: V; foo: T; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } // test if U is a subtype of T, U, V @@ -115,16 +158,22 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. !!! error TS2416: Type 'V' is not assignable to type 'T'. !!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D9 extends C3 { [x: string]: U; foo: U; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D10 extends C3 { [x: string]: V; foo: U; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } // test if V is a subtype of T, U, V @@ -138,6 +187,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D11' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'V' is not assignable to type 'T'. !!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D12 extends C3 { @@ -149,11 +200,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D12' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'V' is not assignable to type 'U'. !!! error TS2416: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D13 extends C3 { [x: string]: V; foo: V; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } // Date > V > U > T @@ -162,21 +217,29 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf class D14 extends C3 { [x: string]: Date; foo: T; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D15 extends C3 { [x: string]: T; foo: T; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D16 extends C3 { [x: string]: U; foo: T; + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D17 extends C3 { [x: string]: V; foo: T; + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } // test if U is a subtype of T, U, V, Date @@ -184,6 +247,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf class D18 extends C3 { [x: string]: Date; foo: T; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D19 extends C3 { @@ -199,16 +264,22 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. !!! error TS2416: Type 'Date' is not assignable to type 'T'. !!! error TS2416: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D20 extends C3 { [x: string]: U; foo: U; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D21 extends C3 { [x: string]: V; foo: U; + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } // test if V is a subtype of T, U, V, Date @@ -216,6 +287,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf class D22 extends C3 { [x: string]: Date; foo: T; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D23 extends C3 { @@ -229,6 +302,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. !!! error TS2416: Type 'Date' is not assignable to type 'T'. !!! error TS2416: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D24 extends C3 { @@ -242,11 +317,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. !!! error TS2416: Type 'Date' is not assignable to type 'U'. !!! error TS2416: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D25 extends C3 { [x: string]: V; foo: V; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } // test if Date is a subtype of T, U, V, Date @@ -254,6 +333,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf class D26 extends C3 { [x: string]: Date; foo: Date; // ok + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D27 extends C3 { @@ -265,6 +346,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D27' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'Date' is not assignable to type 'T'. !!! error TS2416: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D28 extends C3 { @@ -276,6 +359,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D28' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'Date' is not assignable to type 'U'. !!! error TS2416: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } class D29 extends C3 { @@ -287,4 +372,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D29' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'Date' is not assignable to type 'V'. !!! error TS2416: 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'C3'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file From a645ca9839005137d824622d245a16055092458e Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 19 Sep 2019 10:51:09 -0700 Subject: [PATCH 14/17] Do not error when base parent is interface --- src/compiler/checker.ts | 2 ++ ...ninitializedPropertyDeclaration.errors.txt | 14 ++++++++++++- ...derivedUninitializedPropertyDeclaration.js | 21 +++++++++++++++++++ ...edUninitializedPropertyDeclaration.symbols | 21 +++++++++++++++++++ ...ivedUninitializedPropertyDeclaration.types | 16 ++++++++++++++ ...derivedUninitializedPropertyDeclaration.ts | 9 ++++++++ 6 files changed, 82 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 308ddaac6427f..5b81f34370369 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29518,7 +29518,9 @@ namespace ts { } if (base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) { const uninitialized = find(derived.declarations, d => d.kind === SyntaxKind.PropertyDeclaration && !(d as PropertyDeclaration).initializer); + const baseParent = getParentOfSymbol(base); if (uninitialized + && !(baseParent && baseParent.flags & SymbolFlags.Interface) && !(derived.flags & SymbolFlags.Transient) && !(baseDeclarationFlags & ModifierFlags.Abstract) && !(derivedDeclarationFlags & ModifierFlags.Abstract) diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt index 62c7aedfbbea7..b2365be06bca4 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -7,9 +7,10 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2610: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(39,5): error TS2610: Property 'p1' will overwrite the base property in 'E'. Add a 'declare' modifier or an initializer to avoid this. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(62,5): error TS2564: Property 'q' has no initializer and is not definitely assigned in the constructor. -==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (9 errors) ==== +==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (10 errors) ==== class A { property = 'x'; m() { return 1 } @@ -82,4 +83,15 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP abstract p1: 'a' | 'b' | 'c' declare abstract p2: 'a' | 'b' | 'c' } + + interface I { + q: number + } + interface J extends I { } + class K { } + class L extends K { + q: 1 | 2 | 3 // ok, extends a property from an interface + ~ +!!! error TS2564: Property 'q' has no initializer and is not definitely assigned in the constructor. + } \ No newline at end of file diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js index decc56a4867c2..4849a443fd145 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js @@ -53,6 +53,15 @@ abstract class H extends E { abstract p1: 'a' | 'b' | 'c' declare abstract p2: 'a' | 'b' | 'c' } + +interface I { + q: number +} +interface J extends I { } +class K { } +class L extends K { + q: 1 | 2 | 3 // ok, extends a property from an interface +} //// [derivedUninitializedPropertyDeclaration.js] @@ -155,3 +164,15 @@ var H = /** @class */ (function (_super) { } return H; }(E)); +var K = /** @class */ (function () { + function K() { + } + return K; +}()); +var L = /** @class */ (function (_super) { + __extends(L, _super); + function L() { + return _super !== null && _super.apply(this, arguments) || this; + } + return L; +}(K)); diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols index 2ed91c2c2d172..668a0053ed579 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols @@ -120,3 +120,24 @@ abstract class H extends E { >p2 : Symbol(H.p2, Decl(derivedUninitializedPropertyDeclaration.ts, 51, 32)) } +interface I { +>I : Symbol(I, Decl(derivedUninitializedPropertyDeclaration.ts, 53, 1)) + + q: number +>q : Symbol(I.q, Decl(derivedUninitializedPropertyDeclaration.ts, 55, 13)) +} +interface J extends I { } +>J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1)) +>I : Symbol(I, Decl(derivedUninitializedPropertyDeclaration.ts, 53, 1)) + +class K { } +>K : Symbol(K, Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25)) + +class L extends K { +>L : Symbol(L, Decl(derivedUninitializedPropertyDeclaration.ts, 59, 11)) +>K : Symbol(K, Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25)) + + q: 1 | 2 | 3 // ok, extends a property from an interface +>q : Symbol(L.q, Decl(derivedUninitializedPropertyDeclaration.ts, 60, 19)) +} + diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types index aa4e7ba501e42..63cc5d59ec47c 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types @@ -127,3 +127,19 @@ abstract class H extends E { >p2 : "a" | "b" | "c" } +interface I { + q: number +>q : number +} +interface J extends I { } +class K { } +>K : K + +class L extends K { +>L : L +>K : K + + q: 1 | 2 | 3 // ok, extends a property from an interface +>q : 1 | 2 | 3 +} + diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts index a3f126c10aec8..a590d667a4a81 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts @@ -53,3 +53,12 @@ abstract class H extends E { abstract p1: 'a' | 'b' | 'c' declare abstract p2: 'a' | 'b' | 'c' } + +interface I { + q: number +} +interface J extends I { } +class K { } +class L extends K { + q: 1 | 2 | 3 // ok, extends a property from an interface +} From 030c768d91d4dfc61b2ca60fa94836098a64ddb1 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 19 Sep 2019 11:58:46 -0700 Subject: [PATCH 15/17] Fix base interface check --- src/compiler/checker.ts | 3 +-- ...ninitializedPropertyDeclaration.errors.txt | 13 ++++++---- ...derivedUninitializedPropertyDeclaration.js | 26 +++++++++++-------- ...edUninitializedPropertyDeclaration.symbols | 22 ++++++++++------ ...ivedUninitializedPropertyDeclaration.types | 17 ++++++++---- ...derivedUninitializedPropertyDeclaration.ts | 9 ++++--- 6 files changed, 56 insertions(+), 34 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5b81f34370369..30d671748c74c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29518,9 +29518,8 @@ namespace ts { } if (base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) { const uninitialized = find(derived.declarations, d => d.kind === SyntaxKind.PropertyDeclaration && !(d as PropertyDeclaration).initializer); - const baseParent = getParentOfSymbol(base); if (uninitialized - && !(baseParent && baseParent.flags & SymbolFlags.Interface) + && !(base.valueDeclaration && base.valueDeclaration.parent.kind === SyntaxKind.InterfaceDeclaration) && !(derived.flags & SymbolFlags.Transient) && !(baseDeclarationFlags & ModifierFlags.Abstract) && !(derivedDeclarationFlags & ModifierFlags.Abstract) diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt index b2365be06bca4..0c0fda3415616 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2610: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(39,5): error TS2610: Property 'p1' will overwrite the base property in 'E'. Add a 'declare' modifier or an initializer to avoid this. -tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(62,5): error TS2564: Property 'q' has no initializer and is not definitely assigned in the constructor. +tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(65,5): error TS2610: Property 'r' will overwrite the base property in 'J'. Add a 'declare' modifier or an initializer to avoid this. ==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (10 errors) ==== @@ -88,10 +88,13 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP q: number } interface J extends I { } - class K { } - class L extends K { - q: 1 | 2 | 3 // ok, extends a property from an interface + class J { + r = 5 + } + class K extends J { + q!: 1 | 2 | 3 // ok, extends a property from an interface + r!: 4 | 5 // error, from class ~ -!!! error TS2564: Property 'q' has no initializer and is not definitely assigned in the constructor. +!!! error TS2610: Property 'r' will overwrite the base property in 'J'. Add a 'declare' modifier or an initializer to avoid this. } \ No newline at end of file diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js index 4849a443fd145..471cd5bbf1d18 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js @@ -58,9 +58,12 @@ interface I { q: number } interface J extends I { } -class K { } -class L extends K { - q: 1 | 2 | 3 // ok, extends a property from an interface +class J { + r = 5 +} +class K extends J { + q!: 1 | 2 | 3 // ok, extends a property from an interface + r!: 4 | 5 // error, from class } @@ -164,15 +167,16 @@ var H = /** @class */ (function (_super) { } return H; }(E)); -var K = /** @class */ (function () { - function K() { +var J = /** @class */ (function () { + function J() { + this.r = 5; } - return K; + return J; }()); -var L = /** @class */ (function (_super) { - __extends(L, _super); - function L() { +var K = /** @class */ (function (_super) { + __extends(K, _super); + function K() { return _super !== null && _super.apply(this, arguments) || this; } - return L; -}(K)); + return K; +}(J)); diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols index 668a0053ed579..87e912887042a 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols @@ -127,17 +127,23 @@ interface I { >q : Symbol(I.q, Decl(derivedUninitializedPropertyDeclaration.ts, 55, 13)) } interface J extends I { } ->J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1)) +>J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1), Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25)) >I : Symbol(I, Decl(derivedUninitializedPropertyDeclaration.ts, 53, 1)) -class K { } ->K : Symbol(K, Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25)) +class J { +>J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1), Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25)) -class L extends K { ->L : Symbol(L, Decl(derivedUninitializedPropertyDeclaration.ts, 59, 11)) ->K : Symbol(K, Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25)) + r = 5 +>r : Symbol(J.r, Decl(derivedUninitializedPropertyDeclaration.ts, 59, 9)) +} +class K extends J { +>K : Symbol(K, Decl(derivedUninitializedPropertyDeclaration.ts, 61, 1)) +>J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1), Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25)) + + q!: 1 | 2 | 3 // ok, extends a property from an interface +>q : Symbol(K.q, Decl(derivedUninitializedPropertyDeclaration.ts, 62, 19)) - q: 1 | 2 | 3 // ok, extends a property from an interface ->q : Symbol(L.q, Decl(derivedUninitializedPropertyDeclaration.ts, 60, 19)) + r!: 4 | 5 // error, from class +>r : Symbol(K.r, Decl(derivedUninitializedPropertyDeclaration.ts, 63, 17)) } diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types index 63cc5d59ec47c..d9c96f0c9fc07 100644 --- a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types @@ -132,14 +132,21 @@ interface I { >q : number } interface J extends I { } -class K { } ->K : K +class J { +>J : J -class L extends K { ->L : L + r = 5 +>r : number +>5 : 5 +} +class K extends J { >K : K +>J : J - q: 1 | 2 | 3 // ok, extends a property from an interface + q!: 1 | 2 | 3 // ok, extends a property from an interface >q : 1 | 2 | 3 + + r!: 4 | 5 // error, from class +>r : 5 | 4 } diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts index a590d667a4a81..e2d7494dd6891 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts @@ -58,7 +58,10 @@ interface I { q: number } interface J extends I { } -class K { } -class L extends K { - q: 1 | 2 | 3 // ok, extends a property from an interface +class J { + r = 5 +} +class K extends J { + q!: 1 | 2 | 3 // ok, extends a property from an interface + r!: 4 | 5 // error, from class } From 003d04151547cc14d6e613ff6b25c737fd730534 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 19 Sep 2019 12:40:12 -0700 Subject: [PATCH 16/17] Add missed baselines --- ...erfaceExtendsObjectIntersection.errors.txt | 78 ------------------- ...ExtendsObjectIntersectionErrors.errors.txt | 5 +- 2 files changed, 1 insertion(+), 82 deletions(-) delete mode 100644 tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt deleted file mode 100644 index f23383cda97cc..0000000000000 --- a/tests/baselines/reference/interfaceExtendsObjectIntersection.errors.txt +++ /dev/null @@ -1,78 +0,0 @@ -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(20,38): error TS2610: Property 'x' will overwrite the base property in 'I1'. Add a 'declare' modifier or an initializer to avoid this. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(21,38): error TS2610: Property 'x' will overwrite the base property in 'I2'. Add a 'declare' modifier or an initializer to avoid this. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(22,38): error TS2610: Property 'x' will overwrite the base property in 'I3'. Add a 'declare' modifier or an initializer to avoid this. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(23,38): error TS2610: Property 'x' will overwrite the base property in 'I4'. Add a 'declare' modifier or an initializer to avoid this. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(24,38): error TS2610: Property 'x' will overwrite the base property in 'I5'. Add a 'declare' modifier or an initializer to avoid this. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(25,38): error TS2610: Property 'x' will overwrite the base property in 'I6'. Add a 'declare' modifier or an initializer to avoid this. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts(26,38): error TS2610: Property 'x' will overwrite the base property in 'I7'. Add a 'declare' modifier or an initializer to avoid this. - - -==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts (7 errors) ==== - type T1 = { a: number }; - type T2 = T1 & { b: number }; - type T3 = () => void; - type T4 = new () => { a: number }; - type T5 = number[]; - type T6 = [string, number]; - type T7 = { [P in 'a' | 'b' | 'c']: string }; - - interface I1 extends T1 { x: string } - interface I2 extends T2 { x: string } - interface I3 extends T3 { x: string } - interface I4 extends T4 { x: string } - interface I5 extends T5 { x: string } - interface I6 extends T6 { x: string } - interface I7 extends T7 { x: string } - - type Constructor = new () => T; - declare function Constructor(): Constructor; - - class C1 extends Constructor() { x: string } - ~ -!!! error TS2610: Property 'x' will overwrite the base property in 'I1'. Add a 'declare' modifier or an initializer to avoid this. - class C2 extends Constructor() { x: string } - ~ -!!! error TS2610: Property 'x' will overwrite the base property in 'I2'. Add a 'declare' modifier or an initializer to avoid this. - class C3 extends Constructor() { x: string } - ~ -!!! error TS2610: Property 'x' will overwrite the base property in 'I3'. Add a 'declare' modifier or an initializer to avoid this. - class C4 extends Constructor() { x: string } - ~ -!!! error TS2610: Property 'x' will overwrite the base property in 'I4'. Add a 'declare' modifier or an initializer to avoid this. - class C5 extends Constructor() { x: string } - ~ -!!! error TS2610: Property 'x' will overwrite the base property in 'I5'. Add a 'declare' modifier or an initializer to avoid this. - class C6 extends Constructor() { x: string } - ~ -!!! error TS2610: Property 'x' will overwrite the base property in 'I6'. Add a 'declare' modifier or an initializer to avoid this. - class C7 extends Constructor() { x: string } - ~ -!!! error TS2610: Property 'x' will overwrite the base property in 'I7'. Add a 'declare' modifier or an initializer to avoid this. - - declare function fx(x: string): string; - declare class CX { a: number } - declare enum EX { A, B, C } - declare namespace NX { export const a = 1 } - - type T10 = typeof fx; - type T11 = typeof CX; - type T12 = typeof EX; - type T13 = typeof NX; - - interface I10 extends T10 { x: string } - interface I11 extends T11 { x: string } - interface I12 extends T12 { x: string } - interface I13 extends T13 { x: string } - - type Identifiable = { _id: string } & T; - - interface I20 extends Partial { x: string } - interface I21 extends Readonly { x: string } - interface I22 extends Identifiable { x: string } - interface I23 extends Identifiable { x: string } - - class C20 extends Constructor>() { x: string } - class C21 extends Constructor>() { x: string } - class C22 extends Constructor>() { x: string } - class C23 extends Constructor>() { x: string } - \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt index 88f9150adc11d..cf04e9cbc4221 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt @@ -22,7 +22,6 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,38): error TS2610: Property 'b' will overwrite the base property in 'T2'. Add a 'declare' modifier or an initializer to avoid this. 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(18,38): error TS2610: Property 'length' will overwrite the base property in 'number[]'. Add a 'declare' modifier or an initializer to avoid this. 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, number]'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,38): error TS2610: Property '0' will overwrite the base property in '[string, number]'. Add a 'declare' modifier or an initializer to avoid this. @@ -60,7 +59,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(47,26): error TS2312: An interface can only extend an object type or intersection of object types with statically known members. -==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts (28 errors) ==== +==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts (27 errors) ==== type T1 = { a: number }; type T2 = T1 & { b: number }; type T3 = number[]; @@ -113,8 +112,6 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI ~~~~~~ !!! 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'. - ~~~~~~ -!!! error TS2610: Property 'length' will overwrite the base property in 'number[]'. Add a 'declare' modifier or an initializer to avoid this. class C4 extends Constructor() { 0: number } ~ !!! error TS2416: Property '0' in type 'C4' is not assignable to the same property in base type '[string, number]'. From 1c5f699994332a5cd6fbb22507b1535aca884b84 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 19 Sep 2019 14:04:25 -0700 Subject: [PATCH 17/17] Fix new errors in services --- src/services/services.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 644629ce2af4f..ebf63d246a6e2 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -339,7 +339,6 @@ namespace ts { } class TokenObject extends TokenOrIdentifierObject implements Token { - public symbol!: Symbol; public kind: TKind; constructor(kind: TKind, pos: number, end: number) { @@ -349,9 +348,8 @@ namespace ts { } class IdentifierObject extends TokenOrIdentifierObject implements Identifier { - public kind!: SyntaxKind.Identifier; + public kind: SyntaxKind.Identifier = SyntaxKind.Identifier; public escapedText!: __String; - public symbol!: Symbol; public autoGenerateFlags!: GeneratedIdentifierFlags; _primaryExpressionBrand: any; _memberExpressionBrand: any; @@ -541,7 +539,7 @@ namespace ts { } class SourceFileObject extends NodeObject implements SourceFile { - public kind!: SyntaxKind.SourceFile; + public kind: SyntaxKind.SourceFile = SyntaxKind.SourceFile; public _declarationBrand: any; public fileName!: string; public path!: Path;