diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f8c8817888591..30d671748c74c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29443,7 +29443,6 @@ namespace ts { } 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. @@ -29477,7 +29476,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. @@ -29514,10 +29512,31 @@ 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) { + const uninitialized = find(derived.declarations, d => d.kind === SyntaxKind.PropertyDeclaration && !(d as PropertyDeclaration).initializer); + if (uninitialized + && !(base.valueDeclaration && base.valueDeclaration.parent.kind === SyntaxKind.InterfaceDeclaration) + && !(derived.flags & SymbolFlags.Transient) + && !(baseDeclarationFlags & 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; + if ((uninitialized as PropertyDeclaration).exclamationToken + || !constructor + || !isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + 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; + } let errorMessage: DiagnosticMessage; if (isPrototypeProperty(base)) { @@ -29583,6 +29602,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)) { @@ -32507,7 +32529,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) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 44bba361bbc55..957e1911ec3fa 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2204,6 +2204,10 @@ "category": "Error", "code": 2609 }, + "Property '{0}' will overwrite the base property in '{1}'. Add a 'declare' modifier or an initializer to avoid this.": { + "category": "Error", + "code": 2610 + }, "Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": { "category": "Error", "code": 2649 @@ -5144,6 +5148,14 @@ "category": "Message", "code": 95093 }, + "Prefix with 'declare'": { + "category": "Message", + "code": 95094 + }, + "Prefix all incorrect property declarations with 'declare'": { + "category": "Message", + "code": 95095 + }, "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": { "category": "Error", 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/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/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; diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index b90607b0a85a3..5c0e39f9f6564 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/baselines/reference/apparentTypeSubtyping.errors.txt b/tests/baselines/reference/apparentTypeSubtyping.errors.txt index ca2f0765d6211..9f43225eb1594 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: 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 (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: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } 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: 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 a4a8ccc0a8bdd..1dde3b891f812 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: 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 (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: 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 5f46ee70d2aaa..4bdf83b31c789 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: 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'. @@ -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: 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/classExpressionPropertyModifiers.errors.txt b/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt index f4b3fed7e5458..cb01d6561260f 100644 --- a/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt +++ b/tests/baselines/reference/classExpressionPropertyModifiers.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/classExpressionPropertyModifiers.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. +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) ==== const a = class Cat { declare [Symbol.toStringTag] = "uh"; - ~~~~~~~ -!!! error TS1031: 'declare' modifier cannot appear on a class element. + ~~~~ +!!! 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/classIsSubtypeOfBaseType.errors.txt b/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt index 8b84602b807c5..f8369af4ad403 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: 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: 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 (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: 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 } } @@ -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: 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/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/declarationEmitProtectedMembers.errors.txt b/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt new file mode 100644 index 0000000000000..5adfa76f4f627 --- /dev/null +++ b/tests/baselines/reference/declarationEmitProtectedMembers.errors.txt @@ -0,0 +1,55 @@ +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) ==== + // 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: 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(); + } + 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..a7c03264131bb --- /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: 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) ==== + 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: 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: 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) { } + 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..816f3b4df5d25 --- /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: 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) ==== + 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: 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: 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) { } + 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..1be0509e6524d 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: 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'. @@ -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: 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'. @@ -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: 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); } } @@ -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: 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 064e2e8d43c2f..2d11066559826 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: 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: 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 (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: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } 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: 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 9292ff64411d5..45511c1a2c013 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: 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: 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. -==== 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: 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; } ~ @@ -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: 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 new file mode 100644 index 0000000000000..8f65f436dcac8 --- /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: 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) ==== + class Base { + x: { + foo: string; + } + } + + class Derived extends Base { + x: { + ~ +!!! error TS2610: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. + 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..5f8a219b58eb2 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: 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: 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'. @@ -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: 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. @@ -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: 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 e63849e4aa887..6d32d3f814739 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: 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: 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'. @@ -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: 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. @@ -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: 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 new file mode 100644 index 0000000000000..0c0fda3415616 --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt @@ -0,0 +1,100 @@ +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. +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(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) ==== + class A { + property = 'x'; + m() { return 1 } + } + class B extends A { + property: any; // error + ~~~~~~~~ +!!! 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 + } + class BDBang extends A { + 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 + ~~~ +!!! error TS1039: Initializers are not allowed in ambient contexts. + } + class U { + declare nonce: any; // ok, even though there's no base + } + + 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: 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 + } + + + declare class E { + p1: string + p2: string + } + class F extends E { + p1!: 'z' + ~~ +!!! error TS2610: Property 'p1' will overwrite the base property in 'E'. Add a 'declare' modifier or an initializer to avoid this. + 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' + } + + interface I { + q: number + } + interface J extends I { } + 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 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 new file mode 100644 index 0000000000000..471cd5bbf1d18 --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.js @@ -0,0 +1,182 @@ +//// [derivedUninitializedPropertyDeclaration.ts] +class A { + property = 'x'; + m() { return 1 } +} +class B extends A { + property: any; // error +} +class BD extends A { + declare property: any; // ok because it's implicitly initialised +} +class BDBang extends A { + declare property!: any; // ! is not allowed, this is an ambient declaration +} +class BOther extends A { + declare m() { return 2 } // not allowed on methods + 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; // ok, even though there's no base +} + +class C { + p: string; +} +class D extends C { + p: 'hi'; // error +} +class DD extends C { + declare p: 'bye'; // ok +} + + +declare class E { + p1: string + p2: string +} +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' +} + +interface I { + q: number +} +interface J extends I { } +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 +} + + +//// [derivedUninitializedPropertyDeclaration.js] +"use strict"; +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'; + } + A.prototype.m = function () { return 1; }; + return A; +}()); +var B = /** @class */ (function (_super) { + __extends(B, _super); + function B() { + return _super !== null && _super.apply(this, arguments) || this; + } + 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 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() { + } + return C; +}()); +var D = /** @class */ (function (_super) { + __extends(D, _super); + function D() { + return _super !== null && _super.apply(this, arguments) || this; + } + return D; +}(C)); +var DD = /** @class */ (function (_super) { + __extends(DD, _super); + function DD() { + return _super !== null && _super.apply(this, arguments) || this; + } + return DD; +}(C)); +var F = /** @class */ (function (_super) { + __extends(F, _super); + function F() { + return _super !== null && _super.apply(this, arguments) || this; + } + 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)); +var J = /** @class */ (function () { + function J() { + this.r = 5; + } + return J; +}()); +var K = /** @class */ (function (_super) { + __extends(K, _super); + function K() { + return _super !== null && _super.apply(this, arguments) || this; + } + return K; +}(J)); diff --git a/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols new file mode 100644 index 0000000000000..87e912887042a --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.symbols @@ -0,0 +1,149 @@ +=== 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)) + + m() { return 1 } +>m : Symbol(A.m, Decl(derivedUninitializedPropertyDeclaration.ts, 1, 19)) +} +class B extends A { +>B : Symbol(B, Decl(derivedUninitializedPropertyDeclaration.ts, 3, 1)) +>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0)) + + property: any; // error +>property : Symbol(B.property, Decl(derivedUninitializedPropertyDeclaration.ts, 4, 19)) +} +class BD extends A { +>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; // ! is not allowed, this is an ambient declaration +>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 m() { return 2 } // not allowed on methods +>m : Symbol(BOther.m, Decl(derivedUninitializedPropertyDeclaration.ts, 13, 24)) + + 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 +>property : Symbol(BOther.property, Decl(derivedUninitializedPropertyDeclaration.ts, 15, 23)) +} +class U { +>U : Symbol(U, Decl(derivedUninitializedPropertyDeclaration.ts, 17, 1)) + + declare nonce: any; // ok, even though there's no base +>nonce : Symbol(U.nonce, Decl(derivedUninitializedPropertyDeclaration.ts, 18, 9)) +} + +class C { +>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 20, 1)) + + p: string; +>p : Symbol(C.p, Decl(derivedUninitializedPropertyDeclaration.ts, 22, 9)) +} +class D extends C { +>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, 25, 19)) +} +class DD extends C { +>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, 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)) +} + +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)) +} + +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), Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25)) +>I : Symbol(I, Decl(derivedUninitializedPropertyDeclaration.ts, 53, 1)) + +class J { +>J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1), 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)) + + 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 new file mode 100644 index 0000000000000..d9c96f0c9fc07 --- /dev/null +++ b/tests/baselines/reference/derivedUninitializedPropertyDeclaration.types @@ -0,0 +1,152 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts === +class A { +>A : A + + property = 'x'; +>property : string +>'x' : "x" + + m() { return 1 } +>m : () => number +>1 : 1 +} +class B extends A { +>B : B +>A : A + + property: any; // error +>property : any +} +class BD extends A { +>BD : BD +>A : A + + declare property: any; // ok because it's implicitly initialised +>property : any +} +class BDBang extends A { +>BDBang : BDBang +>A : A + + declare property!: any; // ! is not allowed, this is an ambient declaration +>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; // ok, even though it's not in the base +>nonce : any + + declare property = 'y' // initialiser not allowed with declare +>property : string +>'y' : "y" +} +class U { +>U : U + + declare nonce: any; // ok, even though there's no base +>nonce : any +} + +class C { +>C : C + + p: string; +>p : string +} +class D extends C { +>D : D +>C : C + + p: 'hi'; // error +>p : "hi" +} +class DD extends C { +>DD : DD +>C : C + + declare p: 'bye'; // ok +>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" +} + +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" +} + +interface I { + q: number +>q : number +} +interface J extends I { } +class J { +>J : J + + 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 + + r!: 4 | 5 // error, from class +>r : 5 | 4 +} + diff --git a/tests/baselines/reference/genericPrototypeProperty2.errors.txt b/tests/baselines/reference/genericPrototypeProperty2.errors.txt new file mode 100644 index 0000000000000..2d27cf0fc4e72 --- /dev/null +++ b/tests/baselines/reference/genericPrototypeProperty2.errors.txt @@ -0,0 +1,24 @@ +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) ==== + interface EventTarget { x } + class BaseEvent { + target: EventTarget; + } + + class MyEvent extends BaseEvent { + target: T; + ~~~~~~ +!!! 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; + } + + class MyEventWrapper extends BaseEventWrapper { + t: MyEvent; // any satisfies constraint and passes assignability check between 'target' properties + ~ +!!! 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 new file mode 100644 index 0000000000000..c12e29d3da0cc --- /dev/null +++ b/tests/baselines/reference/genericPrototypeProperty3.errors.txt @@ -0,0 +1,23 @@ +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) ==== + class BaseEvent { + target: {}; + } + + class MyEvent extends BaseEvent { // T is instantiated to any in the prototype, which is assignable to {} + target: T; + ~~~~~~ +!!! 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; + } + + class MyEventWrapper extends BaseEventWrapper { + t: MyEvent; + ~ +!!! 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/illegalModifiersOnClassElements.errors.txt b/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt index eb373ad2fae07..99ba043b52a80 100644 --- a/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt +++ b/tests/baselines/reference/illegalModifiersOnClassElements.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/illegalModifiersOnClassElements.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. +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) ==== class C { declare foo = 1; - ~~~~~~~ -!!! error TS1031: 'declare' modifier cannot appear on a class element. + ~ +!!! 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/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt index ecb3e4664a470..d8cb657aa4305 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: 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 (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: 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 b476f1399b445..45a1dbfc5666e 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: 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'. -==== 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: 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 ec8ec05a8aeb5..3996eaf15c34b 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: Property 'x' will overwrite the base property in 'a'. Add a 'declare' modifier or an initializer to avoid this. -==== 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: 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 new file mode 100644 index 0000000000000..79b3e6a8f1ea8 --- /dev/null +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.errors.txt @@ -0,0 +1,13 @@ +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) ==== + class a { + x: () => string; + } + + class b extends a { + x: () => string; + ~ +!!! 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 84b454d7ea0a6..1d3622f49e79f 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: Property 'x' will overwrite the base property in 'C1'. Add a 'declare' modifier or an initializer to avoid this. -==== 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: 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/interfaceExtendsObjectIntersectionErrors.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt index 17cb5585cf87e..cf04e9cbc4221 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt @@ -16,14 +16,18 @@ 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: 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: 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(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. 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: 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'. @@ -55,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 (23 errors) ==== +==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts (27 errors) ==== type T1 = { a: number }; type T2 = T1 & { b: number }; type T3 = number[]; @@ -96,10 +100,14 @@ 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: 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: 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[]'. @@ -108,10 +116,14 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI ~ !!! 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: 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: 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 c4a440d9a0ea5..2e3788c895de9 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: 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'. -==== 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: 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 new file mode 100644 index 0000000000000..cdb3abea28fee --- /dev/null +++ b/tests/baselines/reference/mutuallyRecursiveInference.errors.txt @@ -0,0 +1,24 @@ +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) ==== + class T { + a: A; + b: any + } + class L extends T { + m() { this.a } + } + class X extends L { + a: 'a' | 'b' + ~ +!!! 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: Property 'b' will overwrite the base property in 'L'. Add a 'declare' modifier or an initializer to avoid this. + m2() { + this.a + } + } + \ 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/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/baselines/reference/parserMemberVariableDeclaration5.errors.txt b/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt deleted file mode 100644 index 2b2ea9664ceb4..0000000000000 --- a/tests/baselines/reference/parserMemberVariableDeclaration5.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -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 (1 errors) ==== - class C { - declare Foo; - ~~~~~~~ -!!! error TS1031: 'declare' modifier cannot appear on a class element. - } \ No newline at end of file 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/protectedMembers.errors.txt b/tests/baselines/reference/protectedMembers.errors.txt index 9171df2a485b6..563a4a757fc6c 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: 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. @@ -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: 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: Property 'x' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. -==== 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: 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(); @@ -147,6 +152,8 @@ tests/cases/compiler/protectedMembers.ts(111,7): error TS2415: Class 'B3' incorr } class B2 extends A2 { x; + ~ +!!! error TS2610: Property 'x' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. } 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: 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 ce24301efc2bf..362da88655557 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: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this. -==== 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: 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 0ec8951fe9391..33f7c1d48ec2d 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: 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 (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: 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/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 diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index 03656c08c4ef2..d951b47e4cff9 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: 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: 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: 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: 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: 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: 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 (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: 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: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } 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: 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: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } 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: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } 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: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } 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: 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: Property 'foo' will overwrite the base property in 'B1'. Add a 'declare' modifier or an initializer to avoid this. } 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: 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 700076db4d190..f1c67351d3370 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 (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: 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 { @@ -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: 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 { @@ -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: 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 { @@ -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: 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: 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 { @@ -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: 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 { @@ -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: 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 { @@ -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: 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: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. } } @@ -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: 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 { @@ -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: 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 { @@ -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: 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 { @@ -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: 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 { @@ -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: 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 { @@ -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: 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 { @@ -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: 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 { @@ -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: 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: 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 new file mode 100644 index 0000000000000..aed2b0a7220b7 --- /dev/null +++ b/tests/baselines/reference/subtypingTransitivity.errors.txt @@ -0,0 +1,28 @@ +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) ==== + class B { + x: Object; + } + + class D extends B { + public x: string; + ~ +!!! 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: Property 'x' will overwrite the base property in 'B'. Add a 'declare' modifier or an initializer to avoid this. + } + + 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..140fef4236192 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: 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: 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: 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: 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: 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: 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: 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 (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: 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: Property 'bar' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. } class A2 { @@ -39,10 +55,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B2 extends A2 { 1: Derived; // ok + ~ +!!! 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: Property '2.0' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. } class A3 { @@ -52,10 +72,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A3 { '1': Derived; // ok + ~~~ +!!! 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: Property ''2.0'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this. } module TwoLevels { @@ -66,10 +90,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { foo: Derived2; // ok + ~~~ +!!! 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: Property 'bar' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this. } class A2 { @@ -79,10 +107,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B2 extends A2 { 1: Derived2; // ok + ~ +!!! 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: Property '2.0' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this. } class A3 { @@ -92,9 +124,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A3 { '1': Derived2; // ok + ~~~ +!!! 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: 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 new file mode 100644 index 0000000000000..602526de4dfcc --- /dev/null +++ b/tests/baselines/reference/tsxGenericAttributesType5.errors.txt @@ -0,0 +1,19 @@ +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) ==== + import React = require('react'); + + class B1 extends React.Component { + render() { + return
hi
; + } + } + class B extends React.Component { + props: U; + ~~~~~ +!!! error TS2610: Property 'props' will overwrite the base property in 'Component'. Add a 'declare' modifier or an initializer to avoid this. + 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..a75ae10b22a2d --- /dev/null +++ b/tests/baselines/reference/tsxGenericAttributesType6.errors.txt @@ -0,0 +1,19 @@ +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) ==== + import React = require('react'); + + class B1 extends React.Component { + render() { + return
hi
; + } + } + class B extends React.Component { + props: U; + ~~~~~ +!!! error TS2610: Property 'props' will overwrite the base property in 'Component'. Add a 'declare' modifier or an initializer to avoid this. + 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..021d240b8a533 --- /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: 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) ==== + // 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. + } + + interface I1 { + bar: string; + } + class D9 extends Base { + foo: I1; + ~~~ +!!! 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: 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: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. + } + + function f() { } + module f { + export var bar = 1; + } + class D12 extends Base { + foo: typeof f; + ~~~ +!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this. + } + + + class c { baz: string } + module c { + export var bar = 1; + } + class D13 extends Base { + foo: typeof c; + ~~~ +!!! 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: 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: 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; + //} + + + class D16 extends Base { + foo: Object; + ~~~ +!!! 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: 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 diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts new file mode 100644 index 0000000000000..e2d7494dd6891 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts @@ -0,0 +1,67 @@ +// @strict: true +class A { + property = 'x'; + m() { return 1 } +} +class B extends A { + property: any; // error +} +class BD extends A { + declare property: any; // ok because it's implicitly initialised +} +class BDBang extends A { + declare property!: any; // ! is not allowed, this is an ambient declaration +} +class BOther extends A { + declare m() { return 2 } // not allowed on methods + 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; // ok, even though there's no base +} + +class C { + p: string; +} +class D extends C { + p: 'hi'; // error +} +class DD extends C { + declare p: 'bye'; // ok +} + + +declare class E { + p1: string + p2: string +} +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' +} + +interface I { + q: number +} +interface J extends I { } +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 +} 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 +}` +}); 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; 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);