This vastly improves our error tolerance and messages for when the user writes an illegal heritage clause sequence.
57 lines
No EOL
1.9 KiB
Text
57 lines
No EOL
1.9 KiB
Text
tests/cases/compiler/multipleInheritance.ts(9,21): error TS1174: Classes can only extend a single class.
|
|
tests/cases/compiler/multipleInheritance.ts(18,21): error TS1174: Classes can only extend a single class.
|
|
tests/cases/compiler/multipleInheritance.ts(34,7): error TS2415: Class 'Baad' incorrectly extends base class 'Good'.
|
|
Types of property 'g' are incompatible.
|
|
Type '(n: number) => number' is not assignable to type '() => number'.
|
|
tests/cases/compiler/multipleInheritance.ts(35,12): error TS2425: Class 'Good' defines instance member property 'f', but extended class 'Baad' defines it as instance member function.
|
|
|
|
|
|
==== tests/cases/compiler/multipleInheritance.ts (4 errors) ====
|
|
class B1 {
|
|
public x;
|
|
}
|
|
|
|
class B2 {
|
|
public x;
|
|
}
|
|
|
|
class C extends B1, B2 { // duplicate member
|
|
~~
|
|
!!! error TS1174: Classes can only extend a single class.
|
|
}
|
|
|
|
class D1 extends B1 {
|
|
}
|
|
|
|
class D2 extends B2 {
|
|
}
|
|
|
|
class E extends D1, D2 { // nope, duplicate member
|
|
~~
|
|
!!! error TS1174: Classes can only extend a single class.
|
|
}
|
|
|
|
class N {
|
|
public y:number;
|
|
}
|
|
|
|
class ND extends N { // any is assignable to number
|
|
public y;
|
|
}
|
|
|
|
class Good {
|
|
public f:() => number = function() { return 0; }
|
|
public g() { return 0; }
|
|
}
|
|
|
|
class Baad extends Good {
|
|
~~~~
|
|
!!! error TS2415: Class 'Baad' incorrectly extends base class 'Good'.
|
|
!!! error TS2415: Types of property 'g' are incompatible.
|
|
!!! error TS2415: Type '(n: number) => number' is not assignable to type '() => number'.
|
|
public f(): number { return 0; }
|
|
~
|
|
!!! error TS2425: Class 'Good' defines instance member property 'f', but extended class 'Baad' defines it as instance member function.
|
|
public g(n:number) { return 0; }
|
|
}
|
|
|