2014-10-28 08:28:59 +01:00
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassTransitivity3.ts(18,1): error TS2323: Type 'E<string>' is not assignable to type 'C<string>'.
Types of property 'foo' are incompatible.
Type '(x: string, y?: number) => void' is not assignable to type '(x: string, y: string) => void'.
Types of parameters 'y' and 'y' are incompatible.
2014-09-12 22:35:07 +02:00
Type 'number' is not assignable to type 'string'.
2014-07-13 01:04:16 +02:00
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassTransitivity3.ts (1 errors) ====
// subclassing is not transitive when you can remove required parameters and add optional parameters
class C<T> {
foo(x: T, y: T) { }
}
class D<T> extends C<T> {
foo(x: T) { } // ok to drop parameters
}
class E<T> extends D<T> {
foo(x: T, y?: number) { } // ok to add optional parameters
}
var c: C<string>;
var d: D<string>;
var e: E<string>;
c = e;
~
2014-10-28 08:28:59 +01:00
!!! error TS2323: Type 'E<string>' is not assignable to type 'C<string>'.
!!! error TS2323: Types of property 'foo' are incompatible.
!!! error TS2323: Type '(x: string, y?: number) => void' is not assignable to type '(x: string, y: string) => void'.
!!! error TS2323: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2323: Type 'number' is not assignable to type 'string'.
2014-07-13 01:04:16 +02:00
var r = c.foo('', '');
var r2 = e.foo('', 1);