1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(10,7): error TS2415: Class 'D' incorrectly extends base class 'C'.
Types have separate declarations of a private property 'x'.
tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(10,7): error TS2420: Class 'D' incorrectly implements interface 'I'.
Types have separate declarations of a private property 'x'.
tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(20,13): error TS2416: Property 'x' in type 'D2' is not assignable to the same property in base type 'C'.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(20,13): error TS2416: Property 'x' in type 'D2' is not assignable to the same property in base type 'I'.
Type 'string' is not assignable to type 'number'.
==== tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts (4 errors) ====
class C {
public foo(x: any) { return x; }
private x = 1;
}
interface I extends C {
other(x: any): any;
}
class D extends C implements I { // error
~
!!! error TS2415: Class 'D' incorrectly extends base class 'C'.
!!! error TS2415: Types have separate declarations of a private property 'x'.
~
!!! error TS2420: Class 'D' incorrectly implements interface 'I'.
!!! error TS2420: Types have separate declarations of a private property 'x'.
public foo(x: any) { return x; }
private x = 2;
private y = 3;
other(x: any) { return x; }
bar() {}
}
class D2 extends C implements I { // error
public foo(x: any) { return x; }
private x = "";
~
!!! error TS2416: Property 'x' in type 'D2' is not assignable to the same property in base type 'C'.
!!! error TS2416: Type 'string' is not assignable to type 'number'.
~
!!! error TS2416: Property 'x' in type 'D2' is not assignable to the same property in base type 'I'.
!!! error TS2416: Type 'string' is not assignable to type 'number'.
other(x: any) { return x; }
bar() { }
}
|