47 lines
No EOL
1.4 KiB
Text
47 lines
No EOL
1.4 KiB
Text
tests/cases/compiler/inheritance.ts(30,7): error TS2415: Class 'Baad' incorrectly extends base class 'Good'.
|
|
Types of property 'g' are incompatible.
|
|
Type '(n: number) => number' is not assignable to type '() => number'.
|
|
tests/cases/compiler/inheritance.ts(31,12): error TS2425: Class 'Good' defines instance member property 'f', but extended class 'Baad' defines it as instance member function.
|
|
|
|
|
|
==== tests/cases/compiler/inheritance.ts (2 errors) ====
|
|
class B1 {
|
|
public x;
|
|
}
|
|
|
|
class B2 {
|
|
public x;
|
|
}
|
|
|
|
|
|
class D1 extends B1 {
|
|
}
|
|
|
|
class D2 extends B2 {
|
|
}
|
|
|
|
|
|
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; }
|
|
}
|
|
|