2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/extendAndImplementTheSameBaseType2.ts (3 errors) ====
|
|
|
|
class C<T> {
|
|
|
|
foo: number
|
|
|
|
bar(): T {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class D extends C<string> implements C<number> {
|
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2421: Class 'D' incorrectly implements interface 'C<number>':
|
|
|
|
!!! error TS2421: Types of property 'bar' are incompatible:
|
|
|
|
!!! error TS2421: Type '() => string' is not assignable to type '() => number':
|
|
|
|
!!! error TS2421: Type 'string' is not assignable to type 'number'.
|
2014-07-13 01:04:16 +02:00
|
|
|
baz() { }
|
|
|
|
}
|
|
|
|
|
|
|
|
var d: D = new D();
|
|
|
|
var r: string = d.foo;
|
2014-07-19 02:30:06 +02:00
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'number' is not assignable to type 'string'.
|
2014-07-13 01:04:16 +02:00
|
|
|
var r2: number = d.foo;
|
|
|
|
|
|
|
|
var r3: string = d.bar();
|
|
|
|
var r4: number = d.bar();
|
2014-07-19 02:30:06 +02:00
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'string' is not assignable to type 'number'.
|